Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

12c sending numeric data (arduino to NodeMCU)

Status
Not open for further replies.

ark5230

Advanced Member level 3
Advanced Member level 3
Joined
Jun 29, 2009
Messages
862
Helped
163
Reputation
324
Reaction score
140
Trophy points
1,323
Location
India
Activity points
6,187
I am trying to send three numbers like 345, 745, 1 to the nodemcu from arduino but am confused in strings and character array.
Pleas suggest some example or link to the appropriate resource.
This is to be sent to something like ThingSpeak server for IoT
 

Step 1: understand that I2C (and SPI and UART and similar) transfer/exchange values but put no interpretation on what those values mean. Typically I2C will transfer bytes.
Step 2: you need to determine how you want to use the I2C mechanism to transfer your 'numbers'. Perhaps the numbers are 8, 16 or 32 bit integers in which case you use I2C to transfer 1, 2 or 4 bytes respectively. Perhaps the numbers are strings (as you suggest in your question) in which case you send however many bytes (assuming each character in the string is a byte and not UTF-16 and the like) make up the string - also remembering you may need some additional means to signal that the last byte has been sent such as a NULL value or have all of the bytes in some order within a single I2C transaction.
Step 3: write the appropriate code in your NodeMCU and your Arduino in whatever language you want to use in each.
Susan
 
I used arduino slave and Nodemcu master codes from the following tutorial. The two are sending test messages. Nodemcu is sending "Hello Arduino" and arduino is sending "Hello Nodemcu". The communication is running perfectly. both are receiving the test properly.
But when I make a string and save it in a String variable, it is not functioning. If the above text in quotes is a string, why it is not able to use the string I make.
If the three numbers are stored in int a, int b and int c I construct a string
String s = String (a) + String (b) + String (c)
this is not working kindly advise how to handle this

https://www.electronicwings.com/nodemcu/nodemcu-i2c-with-arduino-ide
 

What does "not functioning" mean? Is there smoke and flames? Are you getting any data?
--- Updated ---

What does "not functioning" mean? Is there smoke and flames? Are you getting any data?
--- Updated ---

What does "not functioning" mean? Is there smoke and flames? Are you getting any data?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top