Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By JyotiRajSharma
#61934 Hi,
I think now I am able to do basic I2C communication between Arduino and ESP8266.
I am curious to know that instead of I2C communication, can we do MQTT communication between arduino and ESP8266 ( or mqtt has to be done via I2C bus only)??

My next requirement is to communicate between Raspberry Pi and ESP8266.

Can I upload my slave side code (Arduino) into Raspberry Pi or it has to be converted into python script first ??

I am not good in python programming, but require Raspberry pi as it has more robust processor to act as Gateway.

Is there anyway to upload my C Slave side (Arduino ) code into Raspberry pi ??
User avatar
By GengusKahn
#61983 Hi there, if you look at the changes to the Serial console this will allow you to run the Serial Console on Pin 2 and the I2C on Pins 1 & 3 with Pin 0 used to generate the Interrupt for the arduino (D2) there will be no reset...... Do not use delay inside an I2C transaction as this will cause problems, the Arduino needs some "Sync" either shared timing or direct trigger(Interrupt) to generate the data required.
I2C communication is easy to use until the timing of the bytes changes, this is why I have used a char transfer and up to 32 bytes....
This is a link to the Arduino IDE & Processing Environment for the PI, the ESP can communicate with the PI using onboard UART...(using Serial.set_tx(2);) you will need to set the Uart to be used by the IDE, search for "minicom setup" for some instructions on how to do this on the pi......(Load a current Jessie Build)

https://www.arduino.cc/download.php?f=/arduino-nightly-linuxarm.tar.xz

http://download.processing.org/processing-3.2.4-linux-armv6hf.tgz

There are some python bits here....

https://github.com/EnvironmentMonitor/ESP8266-DHT11-WiFi_Sensor

Code: Select all  Serial.begin(115200);
  Serial.set_tx(2);
  delay(50);
  Serial.println("\r\n\r\nRe-Starting I2C Arduino Slave.......\r\n");
  digitalWrite(0, HIGH);
  //pinMode(2, OUTPUT);     // I2C Request To Send, ESP8266 to Slave, 0 = Request Ready, 1 = idle
  //digitalWrite(2, HIGH);
  //delay(3000);            // allow all to settle before sending reset to Arduino.....
  pinMode(0, OUTPUT);
  //digitalWrite(0, HIGH);  //
  //delay(10);
  //digitalWrite(0, LOW);
  //delay(5);               // 5 millisec pulse to reset Arduino.....
  //digitalWrite(0, HIGH);
  //delay(3000);            // Arduino Startup delay
  Wire.begin(1,3);            // I2C Bus 0
  delay(70);
  digitalWrite(0, LOW);       // When Set Request To Send Active Slave will refresh data....
  delay(RTSDelay);               
  digitalWrite(0, HIGH);      // Set Request idle
  Wire.beginTransmission(8);
  Wire.requestFrom(8, 6);
  Wire.endTransmission();
  Serial.println("Started I2C Arduino Slave.....\r\n");
  delay(50);
User avatar
By JyotiRajSharma
#61990 Thank you!!!
Now, I have implemeted COAP protocol to send sensor data to nodejs server.
I have used plane COAP protocol. I want to add DTLS security too. Do you have an idea how to add it?
User avatar
By JyotiRajSharma
#62016 Hi,

Now i am able to get data from arduino slave to esp8266 master i.e esp8266 can read sensor data via i2c from arduino slave.

Can master esp8266 write some data onto i2c and slave arduino read the same ?? This is required to control LED from webserver --->esp8266------->arduino led.