Help with my sketch

A whopping $89 plus $10 ship. The insult was a motivator for my pleading for help hahaha. Sometimes I ask for help and end up finding it anyway but this is a real stumper.

The limits are set by dip resistor packs from the factory at 0-10v but you can replace the dip packs as I have done to allow higher voltages. The digital inputs are 0-24v protected and opto isolated too. It was attractive for what I wanted to do and besides I just love terminal strips and din rails.

@kreggly I ran the sketch and commands are echoed repeatedly until a new command is entered. AT returns AT and not ok. It’s something.

Try clearing the buffer at the end.

Also, try changing the baud rate for the ESP. AI Thinker has some strange defaults if I recall.

-when I get my RAW AI Thinker ESP12-e chips, they are set at 115.2Kbaud-
also, -once you do an ā€œupdateā€ using ArduinoIDE, you have effectively overwritten NodeMCU, -so you MAY have to reload the ESP. I’m just…grasping here, trying to help…

Not sure how to do either thing

No clue how to reload nodemcu

are any header pins available? Look for Tx and Rx, should be very close to the ESP chip

Yes there is:

I do like your pi3 idea though, easier for coding dummies like me.

Now that I have less hair I’m trying something new. I gleaned from pld_serial.ino sketch that plduino.h must be declared and plduino : : init must be used when dealing with sketches for this plc. About to try modifying craig’s serial sketch to use serial2 suspecting serial2 might be the line needed.

…i could be wrong…

It’s me and copy paste at this point trying to fart around with their sketches to see what will work but most of the sketches have problems. Seems to me that if they have provided the libraries specific to PLduino then wifi should just work. I suspect from logging into it with my pc that the ipv4 address shown (192.168.4.2 and the router is 192.168.1.1) is preventing it from logging into the router. I feel I’m on the hairy edge of a discovery but then the eyes cross :smile:. Maybe a way through programming I can change the ip address to a static one of my choice. Support at DLI is non-existent as in no tech support dept. oh. keep trying right?

william

it programs via USB, right? I saw a USB interface! So- your Apple or PC or whatever should go out and look for the USB driver-

I’ve def been using the usb for programming. some sketches have the unit doing something on the usb that really screws with the mouse pointer. Some sort of backfeed that affect the usb hub inside the laptop hmmm. I’m hoping to at least this week get to a point where I can send AT commands and get a response from the esp and not just echo. They def are using serial2.

1 Like

it may be good to start a terminal, like PuTTy, and connect JUST the Rx (and ground, of course) from the FT232 to the ESP02 Rx. Separately from the active USB connection.
-to monitor if anything is getting through to the Esp02.
9600 baud. the telltale is squiggles and such.
Probably use the same laptop, just use another USB connection.

I reloaded the demo sketch, put wifi in AP mode and the serial monitor shows initializing then gibberish output. Btw what purpose do .lua files serve in these sketches?

I think with NodeMCU programming, you can communicate using AT commands or Lua scripts.

Agreed, it looks like Serial 2 when you are looking at the assignments on the micro.

Maybe try going back to the simple terminal script and try different baud rates for Serial2, and see if you can get an OK.

Cheers,

Craig

@kreggly Found this sketch on a blogspot and it seems close, changed the serial line to 2 and wonder if the line that says emulate on pins 6, 7 could be changed to fit. currently getting failed to initialize esp and esp wifi shield not present. This sketch was written for esp8266 wpa2 connection.

I’m going thru the schematics now to see if I can find the pin outs. Tried various changes to your serial sketch and no luck so for but I do see your point in keeping that simple and trying to comm with the esp.

William

1 Like

I believe 6 and 7 are the Esp2 Tx and Rx serial ā€œpin numbersā€, based on Esp8266? I’m pretty sure the PLduino is just using the Esp2 as a WiFi module, using it’s Tx and Rx pins- :wink: (says Captain Obvious)
(I quack myself up)
So, probably the Tx and Rx pins on the Esp2 are already routed on the PLduino.
Hmph. Gotta verify the pin assignments on the Esp2.
Of note: I read the Esp2 is limited to 9600 baud using ā€œsome?ā€ software. :wink: Heads up.
Also, it may be that the WiFi module has already been flashed because it is ā€œmatedā€ to the PLduino. The Esp2 may have lost it’s ability to communicate ā€œnormallyā€ through it’s own Tx and Rx, receiving data directly from the Atmega.

-what are we trying to do? Silly me.
Trying to ā€œmateā€ this PLC/data logger to Cayenne via WiFi?

Raspberry Pi3 and a custom PC board hat could do it better and smaller. The Pi3 has TWO SPI busses, each with CS1 and CS0. Pretty easy to have (2) MCP3208 and (2) 16-GPIO expanders. 16 channels in, 16 channels out, 16 channels analog in. This project is screaming for a RasPi-3! The ultimate in WiFi micro-PLC. I’m gonna design it just for kicks. Perhaps it may be built by someone.

Try this 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());
}

Cheers,

Craig

1 Like

It is nice to see that the Esp2 has separate VCC from the AtMega.
This allows you to power the Esp2 directly from the FTDI232 serial adapter,
without powering the AtMega chip.

On the schematics I posted above, it shows the pinout of the Esp2 programming header on the PLduino motherboard. Same as always, start your ArduinoIDE, set your baud and serial port, connect the FTDI Tx with Esp2 Rx, FTDI Rx to Esp2 Tx, ground GP0, apply Gnd and +3v3 from the FTDI, -and upload your script directly to the Esp2. After Arduino signifies that an upload transfer has ā€œactuallyā€ begun- remove the gnd from GP0.

I imagine that you’ll want to tell the Esp2 to receive data from the RX pin and transmit via WiFi, and vice versa. not much to talk about… ;/

@Bill I must have missed those schematics you posted. I printed mine and sort of gleaned the connections. The way you laid it out above puts things more into perspective. Seems to me that It’s a straight shot from the atmel (usb) to one side of the esp rxd txd and the other side chpd, gp0 and gp2 run to the Atmega, no? Something about how PLDuino flashed this thing that makes it talk differently perhaps? Don’t forget, I am grasshoppa!