Help with my sketch

probably. You gotta make the Esp2 repeat whatever is being sent thru the USB, plus you gotta assign each variable (or whatever format the PLduino uses) to a virtual thingie (I guess). I’m not a programmer…but I know what needs to be done. We have to take control of that Esp2, and make it connect! I’m supposing that the Atmel is gonna use MQTT to broadcast the I/O? If that is true, it shouldn’t be too difficult to assign the PLduino variables to MQTT publishings.

rs232 to ethernet? Is that a thing? I know nothing about rs232 but this one has one. If I had been on the project, haha, an ethernet would have been included as well!!!

THAT would require another chip- a Uart.

Did you try that last sketch I provided?

I did and got no responses except repeated echo of sent commands. I have an email into DLI to see if they can give tips. The sketch I found and modified for serial2 and PLDuino did respond with failure to initialize and wifi shield not found.

William ****

I received an email back:

Here’s a sketch for uploading files:

https://github.com/digitalloggers/PLDuino/blob/master/Arduino/esp_flash_helper/esp_flash_helper.ino

Basically, it resets the ESP8266, and set its GP0 to high/low, changing the baudrate accordingly - if GP0 is high, it’s NodeMCU’s 9600 to upload Lua scripts, and 115200 otherwise), with on-screen buttons.

Note the ESP8266 runs nodeMCU NodeMcu -- An open-source firmware based on ESP8266 wifi-soc. as supplied, not the AT command set. You can change that if you want.

Hmmm
William

1 Like

Kewl! That’s your whole utility right there! :slight_smile:
Now, just upload the Cayenne bootstrap?

//#define CAYENNE_DEBUG         // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "your token";
// Your network name and password.
char ssid[] = "your ssid";
char password[] = "your password";

void setup()
{
  Serial.begin(115200);
  Cayenne.begin(token, ssid, password);
}

void loop()
{
  Cayenne.run();
}

-So- can you reload NodeMCU? Because once you flash the Esp2…NodeMCU is gone.
You still have to load variables and pass them to Cayenne, I’m guessing by publishing with an MQTT client.

Ok. So you load that up to the Mega and then ckise the Arduino IDE and run the script or app to load the AT command firmware.

Then switch back to run mode and load your Cayenne ESP shield sketch.

Good luck,

Craig

According to DLI, their ESP responds to .lua commands. I can’t fine a table of these commands anywhere, I just want the thing to respond thru the lualoader I downloaded. The ESP is working since I’m able to put it in AP mode and log connect to it. Can putty comm to the IP address of the ESP in AP mode? I’ve never used putty except to connect to a cell phone wirelessly to unlock it.

William

1 Like

I would have expected the data logger to have a proprietary program loaded into the Esp2, -to repeat data from the Arduino. This is gonna be tricky.

I like @kreggly sketch-

#include <PLDuino.h>

void setup()
{
  // Necessary initialization.
  PLDuino::init();
  PLDuino::enableESP();
  
  // Initialization of USB-attached serial.
  Serial.begin(9600);
  
  // Initialization of ESP serial
  Serial2.begin(9600);
}

void loop()
{
  // Simply transfer data from Serial to Serial2 and back.
  if (Serial2.available())
    Serial.write(Serial2.read());
  if (Serial.available())
    Serial2.write(Serial.read());
}

Like I said- the Esp2 is simply being used as a WiFi module- not as a processing module.

I found an AT .bin flash file and an app to flash the ESP. Waiting for a USB to ttl serial card. I had one coming for my next project so I could upload a sketch to a pro mini to operate a motorized indoor wind chime.

When I get the card, connect rxd to txd and txd to rxd correct? And ground.

I only wonder if flashing to AT command firmware will still allow me to code normally as I would any other mega. @kreggly 'S sketch does return something as in gibberish forever so the ESP is talking, just I believe, in something that works with nodemcu.

William

@wmontg5988,

I don’t think you need another cable to program the ESP. You just need to program the Mega with the helper app, and it sets the ESP up to program.

I think that you then use the ESP flash burning application with your Arduino serial port and the program in the Mega will re-direct all data to the ESP.

Cheers,

Craig

I tried flashing the esp with the flash helper loaded and the mega activity light flash in unison with the rxd light on the plc but out of 3 different flash burners none could connect with the esp. I will try the serial to ttl card when it arrives.

William

you must ground GP0 while powering up to get into flash mode.

I got the serial to ttl card and successfully flashed AT firmware but not sure if I got the correct .bin file. Not much on the internet. One flasher app cause the ESP to start spitting out fatal exception errors along with lots of what looked like locations. I flashed by connecting to the header pins by the ESP. Even tho I grounded gp0, I could not flash thru the plduino. I’m sure if I can find a .bin for the ESP-02 that it will flash properly.

Update: Found a different app downloader and finally got AT responses but all come back error. Got ready at first then all errors. Wrong firmware maybe? Any ideas about where to find esp02 firmware if it different?

You need to find ESP-to-Arduino “shield” firmware, so the Esp2 can play nicely with the Arduino- all the esp2 is doing is beigng a WiFi shield. Then, I’m sure the PLduino is using either a MCP3208 or a MCP3008 for the 8 analog inputs, you’ll have to have software for that. Same thing for the I/O ports- unless they are native Arduino, they’re probably running the 8-port expander chips. You can probably see them on the PC board. Does Cayenne do SPI or I2C bus for Arduino officially yet?

It’s time to give in and give up on this crap. I’m out of my depth. @kreggly you want a free PLDuino?

stick with it. you’re almost there!

Here is a site that will generate a firmware file for you based on what you need https://nodemcu-build.com/