Connecting the PLCDuino to Cayenne


#22

Looks like that the zeners will clamp regardless what packs you install. I reinstalled the originals. The lcd reads accurately now but the reading on the dashboard higher. 9.23v = 46.14 on the dashboard / by 5 = 9.238. The voltage level reads correctly on the dashboard if I choose float, I can live with that. Maybe it would be best to just instal voltage dividers at the analog inputs that equal 0-60v = 0 -10v, what you think, simpler solution?

I would like to figure a way to use 1 meg packs but that will have to wait while I grow the sketch using your example to use all the analog inputs as voltage inputs. The digital inputs are a cinch because as I found that cayenne handles the gpio without code if you just need a 2 state reading like say “Solar Rpi online”. That should be easy just having a gpio go high whenever its up and running. Many have noticed that their gpio’s are going high on reboot and suspect it’s because they are inverting state for that actuator.

Have you figured out what you want to do with your plduino? I almost bought a pellet smoker the other day and thought another plduino set up in the outdoor storage with a cable running to the smoker or an outlet receptacle mounted on the outside wall.Hacking hardware is fun. I have an indoor wind chime using a wemos d1.

Thanks

William


#23

@wmontg5988,

The zeners shouldn’t clamp if you just replaced RN1 with the 1Meg packs.

For you, you will want to replace:

float adcVoltage = 10.0*adcVal/1024;

with:

float adcVoltage = 55.0*adcVal/1024;

If you used my sketch, the two numbers should be the same in Cayenne and on the display, save a significant digit or two.

I will probably use my PLCduino to control a home brewery eventually, although, I like having distributed controls, so may just use ESPs.

Cheers,

Craig


#24

Me again! ,

I got thru adding A1 to the code, this is getting a little easier each time. The voltages on the lcd jump back and forth on their own block of yellow, let’s see if I’m right (pos x, pos y, size x, size y)??

William


#25

@wmontg5988,

(top left x, top left y, width, height), but note that the display is 240 wide by 320 high, so it is mounted in the PLCDuino on it’s side :slight_smile:

Here is a good sketch for figuring out how to manage positions on the PLCDuino display:

Cheers,

Craig


#26

So, I’m very excited that I finally got my plduino to connect via wifi. Unfortunately it will only connect if I use my cell phone as a mobile hot spot. I can’t get it to connect to my Google On Hub Router. Any thoughts? I have searched and searched and have found no definite answers. Some think it has to do with the dhcp. Or the type of mode the ESP is in. Client, Server, or Both. I couldn’t find where this can be changed in the code. Or if it has to be changed in one of the library files.


#27

I’ve never used, or heard of, OnHub Router but a quick google search suggests it’s a standard router and should work fine. I kind of wonder if they patched the recent wifi vulnerability and it’s affecting your ESP? I’m honestly not too sure what’s involved in the patch. This link here suggests it has not been patched so might be pointing you in a wrong direction. Can you check if you have any updates past June? Another step I have to ask is to check to see if you have any other devices that can connect.


#28

I have 13 other devices connected to the router. None are esp’s. My router did update in the last 10 days. So maybe it has something to do with the wifi vulnerability. That would be my luck. I’m sure I will figure it out eventually. Just funny that I can get my mobile hot spot to connect and not the on hub router.


#29

@kreggly has some security connections, maybe he would know if the patch affects esp’s? I’ll read up on it tomorrow to see what I can find. The minimum reading I did tonight suggests you can patch the client or the access point which would make me think it isn’t a problem. One other suggestion I have is to delete whatever you have in the ssid and password variables in your sketch and type them again. I’ve made spelling errors on that too many times to count.


#30

It’s got to be port blocking. Cayenne needs 1883 open. Move your ESP IP to
the DMZ zone in router config and see if it works.

If so, you need to figure out how to create firewall rules.

Cheers,

Craig


#31

Sometimes you feel stupid, Apparently my wifi hotspot from my phone is not case sensitive to the SSID. However, the On Hub is. I’m all connected now. Thank you all for the help. So happy that I have my PLDUINO connected. Now for the rest of the project.


#32

Groovy tunes.

Whatcha building?


#33

Controlling a greenhouse for super hot peppers. Being able to know the
hydroponics system is working.


#34

anyone have any suggestions as how to apply the new Agent 2.0 Mqtt update to the plduino? Keep having library issues, figured its because of the custom 8266shield file , any help would be awesome. thanks!


#35

@tempbmx,

I’m going to try and spank it together this week.

Cheers,

Craig


#36

@desertranger29, @tempbmx, @wmontg5988,

I have a working sketch for the PLDuino tonight. Wasn’t too terrible.

Give me a couple days to make a decent example sketch that includes some reads and writes.

Cheers,

Craig


#37

@desertranger29, @tempbmx, @wmontg5988,

Going to Vancouver next week. No time for clean up. Here’s the sketch that works for me. All it does is read one of the ADC inputs, show it on the built in screen, and dump it out to Cayenne using the new MQTT lib.

Those of you not familiar with the PLCDuino can see based on the includes all the exciting stuff in this little box.

Cheers,

Craig

//#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTESP8266Shield.h>
#include <PLDuino.h>
#include <PLDuinoGUI.h>
#include <TMRpcm_PLDuino.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <PLDuino.h>
#include <PLDTouch.h>
#include <PLDuinoGUI.h>
#include <using_namespace_PLDuinoGUI.h>
#include <DS3232RTC.h>
#include <TimeLib.h>
#include <Wire.h>
#include <avr/io.h>


Adafruit_ILI9341 tft = Adafruit_ILI9341(PLDuino::LCD_CS, PLDuino::LCD_DC);
PLDTouch touch(PLDuino::TOUCH_CS, PLDuino::TOUCH_IRQ);

Button btnVoltage("Volts", ILI9341_YELLOW, ILI9341_BLACK);

// Your network name and password.
char ssid[] = "SSID";
char wifiPassword[] = "PASSWORD";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";


// Set ESP8266 Serial object
#define EspSerial Serial2
ESP8266 wifi(&EspSerial);

void setup()
{
  PLDuino::init();
  PLDuino::enableLCD();
  PLDuino::enableESP();
  tft.begin();
  tft.setRotation(3);
  touch. init(1);

  Serial.begin(9600);
  delay(100);
  // Set ESP8266 baud rate
  EspSerial.begin(115200);
  delay(100);

  Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);

  btnVoltage.setPositionAndSize(60, 70, 200, 100);
  btnVoltage.draw(tft);
}

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

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
	CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
	//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

CAYENNE_OUT(V1)
{
  int adcVal = analogRead(A0);
  float adcVoltage = 10.0*adcVal/1024;
  Cayenne.virtualWrite(V1,adcVoltage);
  btnVoltage.setText(String(adcVoltage));
  btnVoltage.draw(tft);
}

#38

first off thank you kreggly for taking the time to work on this and post it.

second, did you have issues with getting libraries to work? like uninstall Cayenne libs or update plduino libs for any of this?

I ask because I’m almost certain I’ve got the same code, with errors. I spent days trying to figure out what I’m doing wrong but to be honest I’m not a Jedi with the Arduino IDE and wouldnt know a common bug from user mistake. When I get a chance to test your code I’ll update, should be in a hour or so, but regardless thank you again for your time.

enjoy your trip If we don’t hear from you until then!


#39

kreggly,
Where did you get that CayenneMQTTESP8266Shield.h from? I tried your .log file and put it where you said to put and I cannot get the Arduino IDE to recognize it for the life of me. I have tried everything to get this PLDuino on the internet. Any suggestions or help?
Thank You


#40

@tempbmx,

What I do is just move the other Cayenne libraries up out of the libraries folder and into the Arduino folder. You should only need the Cayenne MQTT Arduino lib for this.

I bet you are just missing an & when assigning the WIFI.

It’s a stream. We wear streams now. Streams are cool.

Cheers,

Craig


#41

it kills me saying this but I’m sure your right. when reviewing your code I seen the & and said to myself (well I know I tried changing mine to few variations in that area and where it’s declared above, can’t be that) - as I come from a life of only VB/.net in visual studio.

I don’t doubt I have some library stuff screwed up from having beta and stable arduinoIDE setup, but atleast to my guess after a week of effort, you’ve gotta be right.

thanks again in advance