Go Down

Topic: Robotdyn atmega328 uno r3 + Wifi. How to use it? (Read 463 times) previous topic - next topic

John_berd

Hello everyone!

I am searching for more than a week how to use this board. I know that I need to use the dip switch and I understand how to use it. I know how to upload a sketch to the board and how to upload a sketch to the esp8266 module. But I don't know how to make them communicate. I tried to control different pins from the esp module but it doesn't do nothing. I need to get information from my board to the esp and vice versa. I'm new here! Thanks for your help!

Juraj

it is the same as with esp-01 with an ordinal Uno. you can connect the Serials (with dip switches) or use SoftwareSerial. for SoftwareSerial you must wire a pair of pins of Uno to Serial of the esp8266 with jumper wires.

the RX and TX pins of the esp8266 are on the esp8266 header near the Uno pin 0. the pinout of the header is last in this diagram
https://robotdyn.com/pub/media/0G-00005215==UNO+WiFi-R3-AT328-ESP8266-CH340G/DOCS/PINOUT==0G-00005215==UNO+WiFi-R3-AT328-ESP8266-CH340G.pdf

the Mega+WiFi is a much better option with Serial3 connected to esp8266 with dip switches
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

John_berd

Thanks for you answer.
So I prefer to use deep switches. If I well understand the next step is to have AT commands response but I don't. What may I precisely have to do? Do I need to reflash the ESP? What are next steps?

Juraj

Thanks for you answer.
So I prefer to use deep switches. If I well understand the next step is to have AT commands response but I don't. What may I precisely have to do? Do I need to reflash the ESP? What are next steps?
if you switch Serial to Serial you will disconnect the ATmega from USB. so no upload, no Serial Monitor.

the esp8266 had AT firmware on it. so it is still there if you didn't upload something else
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

John_berd

I don't understand, they said to upload a sketch at the bottom of this page:

https://robotdyn.com/uno-wifi-r3-atmega328p-esp8266-32mb-flash-usb-ttl-ch340g-micro-usb.html

What I did. AT commands are not responding and the led of ESP is well blinking.

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld
AT+CIPMUX=1
AT+CIPSERVER=1,5000
AT+CIPSTO=3600

Are AT commands so importants for esp to Arduino communication or I can manage it by another way? if Yes, how can I do?

Juraj

I don't understand, they said to upload a sketch at the bottom of this page:

https://robotdyn.com/uno-wifi-r3-atmega328p-esp8266-32mb-flash-usb-ttl-ch340g-micro-usb.html

What I did. AT commands are not responding and the led of ESP is well blinking.

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld
AT+CIPMUX=1
AT+CIPSERVER=1,5000
AT+CIPSTO=3600

Are AT commands so importants for esp to Arduino communication or I can manage it by another way? if Yes, how can I do?

you do that the same way like everybody else with an esp-01 wired to Serial or SoftwarSerial of Uno. many possibilities. you can use some firmware in esp8266 and a corresponding library in ATmega or write your own sketch for esp8266 and exchange data and commands with the ATmega sketch. (and sketch for esp8266 and Firmata in ATmega is an exotic option)
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

John_berd

#6
Jan 17, 2019, 02:44 pm Last Edit: Jan 17, 2019, 02:47 pm by John_berd
All is ok after a lot of searches I finally did it, I con now communicate in both directions between esp and arduino.

Code for ESP:

void checkInfoFromArduino()
{
  bool StringReady;
  String json;
 
   while (Serial.available()){
   json=Serial.readString();
   StringReady = true;
  }
  infoAtm = json;
  if (StringReady){
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& root = jsonBuffer.parseObject(json);
    if(!root.success()) {
      //Serial.println("parseObject() failed");
      return ;
    }
    temperature = root["temperature"];
    humidity = root["humidity"];
    hygro[0] = root["hygro1"];
    hygro[1] = root["hygro2"];
    hygro[2] = root["hygro3"];
  }
}

void sendInfoToArduino()
{
  DynamicJsonBuffer jbuffer;
  JsonObject& root = jbuffer.createObject();
  root["humr"] = humidityRequired;
  root["huma"] = humidityActivated;
  root["hyr"] = hygroRequired;
  root["hy1"] = hygroActivated[0];
  root["hy2"] = hygroActivated[1];
  root["hy3"] = hygroActivated[2];
  root.printTo(Serial);
  Serial.println();
}

Code for Arduino:

void sendInfoToESP()
{
  DynamicJsonBuffer jbuffer;
  JsonObject& root = jbuffer.createObject();
  root["temperature"] = temperature;
  root["humidity"] = humidity;
  root["hygro1"] = hygro[0];
  root["hygro2"] = hygro[1];
  root["hygro3"] = hygro[2];
  root.printTo(Serial);
  Serial.println();
}

void checkInfoFromESP()
{
  bool StringReady;
  String jsonString ="";

  if (!Serial.available())
    return ;
  while (Serial.available()){
   jsonString =Serial.readString();
   StringReady = true;
  }
  if (StringReady){
    Serial.println(jsonString);
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& root = jsonBuffer.parseObject(jsonString);
    if (!root.success()) {
        Serial.println("Failed to parse config file");
        return ;
    }
    humidityRequired = root["humr"];
    humidityActivated = root["huma"];
    hygroRequired = root["hyr"];
    hygroActivated[0] = root["hy1"];
    hygroActivated[1] = root["hy2"];
    hygroActivated[2] = root["hy3"];
  }
}

I am sending JSON objects to reed them by each others in TX and RX.

To communicate between Arduino and ESP you will need to activate deep switches 1 and 2.
To upload a sketch on ESP: 5, 6, 7.
To upload on Arduino: 3, 4.
Don't forget to change board options before uploading when switching.

To see what is transferred to ESP from Arduino: 1, 2, 3, 4.
To see what is transferred to Arduino from ESP: 1, 2, 5, 6.
(by opening serial terminal)

CitrusGo

Hi

I am a "newbie" and I am stuck. I just purchased the Robodyn R3 Uno wifi. I can find sketches to put on the ESP8266 to connect to the internet and send numbers to Favoriot web page.  I can load scripts onto the ATMega328 to read a DHT11 temperature and humidity sensor.  I want to read sensors attached to the pins and then send out the data to the internet (e.g. favoriot or php page). I found a tutorial that loaded a sketch onto the ESP8266 that suppose to read a DHT11 and then send it out to favoriot, it did send numbers out out to favoriot, but it was unable to read the DHT11 sensor, it just read "0" (https://github.com/LintangWisesa/RobotDyn_UnoWiFi_Favoriot
).  I did set the dip switches to  1-2 On 3-7 Off to connect the ESP8266 to the ATmega328.

I understand you were able to communicate between the ATmega328 and the ESP8266.  I read there are two ways

(a) connect the RX and TX pins of the ATmega328 and the ESP8266 with jumper leads.

     1) I thought drop down resistors/module must be used between TX of ATmega328 to RX of  ESP8266
      to drop voltage from 5 to 3 v, is this correct?
      2) If I do what is in (1) I guess I can send AT commands to control the Wifi?
      3) If I do what is in (1) does any one know of sketches that can read a sensor from the ATmegae
     238 (e.g. DHT11) and then send the readout it to the ESP to eventually do a POST to a php page or
     favoriot?
(b) use code to communicate bewteen the ATmega328 and the ESP8266
    (1) is see in the code provided was able to send some data to the ESP8266, but then how to you then make is do a POST with this code?

Thank you

Juraj

Hi

I am a "newbie" and I am stuck. I just purchased the Robodyn R3 Uno wifi. I can find sketches to put on the ESP8266 to connect to the internet and send numbers to Favoriot web page.  I can load scripts onto the ATMega328 to read a DHT11 temperature and humidity sensor.  I want to read sensors attached to the pins and then send out the data to the internet (e.g. favoriot or php page). I found a tutorial that loaded a sketch onto the ESP8266 that suppose to read a DHT11 and then send it out to favoriot, it did send numbers out out to favoriot, but it was unable to read the DHT11 sensor, it just read "0" (https://github.com/LintangWisesa/RobotDyn_UnoWiFi_Favoriot
).  I did set the dip switches to  1-2 On 3-7 Off to connect the ESP8266 to the ATmega328.

I understand you were able to communicate between the ATmega328 and the ESP8266.  I read there are two ways

(a) connect the RX and TX pins of the ATmega328 and the ESP8266 with jumper leads.

     1) I thought drop down resistors/module must be used between TX of ATmega328 to RX of  ESP8266
      to drop voltage from 5 to 3 v, is this correct?
      2) If I do what is in (1) I guess I can send AT commands to control the Wifi?
      3) If I do what is in (1) does any one know of sketches that can read a sensor from the ATmegae
     238 (e.g. DHT11) and then send the readout it to the ESP to eventually do a POST to a php page or
     favoriot?
(b) use code to communicate bewteen the ATmega328 and the ESP8266
    (1) is see in the code provided was able to send some data to the ESP8266, but then how to you then make is do a POST with this code?

Thank you
the board has the MCUs wired together RX to TX with level conversion. use the DIP switches.
https://robotdyn.com/uno-wifi-r3-atmega328p-esp8266-32mb-flash-usb-ttl-ch340g-micro-usb.html#description
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Go Up