I'm trying to get started with the CactusMicro Rev2. I downloaded the attached serial monitor sketch from Github, thinking that I would talk to the wifi chip via the IDE's serial monitor.
When the project starts, I get the "Hello Cactus Micro!" line on the serial monitor, but then wrong things happen. I get red errors in the lower part of the IDE. Also, the serial port disconnects (the Cactus is on COM20). It also seems to create a second port (COM21).
I have the IDE set up on COM20 (the correct Cactus port), with board type of Lilypad Arduino USB.
All I want to do at this point is to be able to type AT commands into the Serial Monitor (on COM20 I guess) and see the results in the serial monitor.
I tried this on another development machine using the very latest Arduino IDE, and after the "Hello Cactus Micro!" I get some random characters - almost like the Baud rate is wrong - but it wouldn't be the case since I get the "Hello...".
Can anyone point me to a sketch that I can download and just talk to the Cactus's wifi chip using AT commands and see it's responses? Or tell me what I'm doing wrong?
I'm also a little confused about the two ports. I can understand that there's a second internal serial connection going on (between the ATmega chip and the ESP8266 wifi chip. But it seems like that's somehow getting exposed on the USB connection?
I can get rid of it. But I'm not exactly sure what to change it to since there's a delay in there and the sketch is just a debugging tool. I know WHILEs can cause problems where the processor can't get time to do other things, but in this case, I'm not sure it's the problem.
However, when this runs, the "normal" COM port (used for downloading and talking to the ATmega chip) drops out and then a second COM port activates.
Not that I trust everything I get on-line, but this seems pretty simple - I just want to talk to the Wifi chip via the Arduino IDE Serial Monitor through the ATmega chip as a debugging tool to learn to work the ESP Wifi connection.
If there's another sketch out there that works with the Cactus Micro R2, I'd be happy to play with that as a starting point.
From what I've read, the ATmega talks to the ESP8266 via an internal serial connection.
According to the schematics, in R1 of this device, this internal serial connection is on pins D10/D11 as the default and uses a software serial library to make the communication happen. there is also a hardware option, which ties the ESP8266 to D0/D1 instead.
According to the R2 device schematics, which is what I have, the serial connection for the ESP8266 is tied to D0/D1 - no other options. If I understand Arduinos correctly (which could certainly be wrong), D0/D1 are the lines which are used for Serial.print communications and also for uploading code. Seems to me this would be a conflict - when using Serial.print (etc), that goes over D0/D1. When using Serial1.print (etc). wouldn't that also go over D0/D1?
If not D0/D1, where does Serial1.print (etc) traffic go? And how can the ESP8266 have its serial communications over the same pins?
Something I meant to say earlier, but most of us here have no idea whatsoever what a CactusMicro Rev2 is, so you really should post a link to it as part of your original query.
If it was for example, using a 32U4 with USB functionality, that often causes problems with ports opening and closing. Other than that, I would have to look into it in detail.
As yet, I have not researched it, so do not follow any of the details and thus was just giving general advice. If I get the time later, I can do the research ...
most of us here have no idea whatsoever what a CactusMicro Rev2 is
You are correct, it uses a 32U4 chip. And your comment makes me understand more about how this forum works - I initially was wondering if others worked with this Cactus Micro and could help. But based on what you said, this isn't so much a Cactus Micro question as a question about the chip itself, and applicable to a much wider audience. [Thank you]
Here is the Wiki on the Cactus Micro R2
I've been reading over their information, and clearly there are two USB ports, one for bootloader and one for Serial1 What I'm confused about are:
1-Is the 32U4 like a regular Uno, where D0 and D1 are also the IO pins when using Serial.print (etc)? If so, how can Serial1 also be on the same pins?
2-My goal is to have a debugging monitor, where I can use the Arduino IDE Serial Monitor screen to access Serial., have the sketch echo input from the Serial Monitor screen to Serial1 and have it echo output from Serial1 back to the Monitor screen (Serial.). But I'm very confused about all the port switching that's going on, and which of the two ports go to the USB and when.
Yes, well the 32U4 is indeed the chip characterising the Leonardo or the Pro Micro, so you might as well consider it to be a Leonardo and I do not know whether they have a separate module to install in the IDE or whether you just call it that (Noting that the Leonardo and Micro have separate entries in the IDE for whatever reason).
In any case, this behaviour - changing COM port each time it is reset - is a known peculiarity of the Leonardo/ Micro. You had probably best search on those terms - "New COM Leonardo" to find out the state of knowledge on this - unless someone more familiar with it should pipe up on this thread. (Hopefully?)
I have yet to get my Pro Micros to work at all - I had trouble when I tried some considerable time ago and gave up on it for the time being.
Yes, it does seem to fit the Leonardo flavor. Instructions with this device say to set it as a Lilypad (probably similar to Leonardo).
In trying to boil this down to the simple and then go from there, I made a little BLINK sketch:
String tmp;
void setup() {
Serial.begin(9600);
pinMode(5,OUTPUT);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Hello Cactus Micro! Just Blink!");
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
};
void loop() {
// Serial.println("In Main Code");
while (2 > 1) {
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
Serial.println("Loop");
}
}
When the digitalWrite to pin 13 (which enables the on-board ESP8266) is set low, things work and the LED blinks. But when I change the digitalWrite on pin 13 to HIGH (turning on the ESP8266), I never get to the VOID LOOP code - no blinking LED!
So along with the changing COM port, there's obviously something else I'm missing about this little device.
You are correct - Lillypad USB - which is actually what I've been using. I've been in contact with the Cactus Micro people and I may have a bad unit which is why it keeps resetting (been through possible power issues, etc.). Getting another and will try again. Thanks.