Cactus Micro getting started

Hi,

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?

Thanks,

CactusMicro_Serial_Monitor.ino (603 Bytes)

How about posting your sketch in your request, in “code” tags according to the instructions, so that we can examine the code easily and critique it?

Sorry, wasn’t sure whether to post inline or as attachment. Here it is:

String tmp; 

#define BAUD_RATE 9600

void setup() {
  Serial.begin(BAUD_RATE);
  Serial1.begin(BAUD_RATE); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("Hello Cactus Micro!");
  
  // Enable esp8266 
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);  
};

void loop() {

  while (Serial1.available() > 0)  {
    tmp += char(Serial1.read());
    delay(2);
  }

  if(tmp.length() > 0) {
    Serial.println(tmp);
    tmp = "";
  }

  if (Serial.available()) {
    Serial1.write(Serial.read());
  }
}

Get rid of the "while".

"while" should almost never appear in a microcontroller application.

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.

Thanks,

More info, and now I'm really confused.

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 ...

Very good point

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.

Thanks for bearing with me on this.

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. :astonished:

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.

IraSch:
Yes, it does seem to fit the Leonardo flavor. Instructions with this device say to set it as a Lilypad (probably similar to Leonardo).

Specifically a Lilypad USB. If you set it to plain Lilypad, it should not work (in fact, it should not download at all).

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.

Similar problem here, the Cactus has been working for some minutes then I get the 43 error on usb port: "USB Device Not Recognized".

I change pc (from a win10 desktop to a win 7 laptop) then I try three different cable and I get the same message.

I try to re-install the usb drivers, nothing happen.

I'm stuck.

May be is because I have upload a sketch using the Leonardo board and not the Lillypad USB, it seems this corrupts the bootloader.

https://forum.smartcitizen.me/index.php?p=/discussion/290/unable-to-connect-to-board

I have a cactus micro v2 I am trying to get the ESP8266 to do ANYTHING at all. This same sketch seems to give me the same exact results. I tried the baud hunting sketch and it cannot identify a buadrate.
(cactus-micro-r2/searchBaudRate.ino at master · AprilBrother/cactus-micro-r2 · GitHub)

The mishmash I get in the serial monitor is:

0 Hello Cactus Micro!
1 Hello Cactus Micro!
2 Hello Cactus Micro!
3 Hello Cactus Micro!
4 Hello Cactus Micro!
;$$��<�$�<�$�#<���e�;�##��''�’‘���#8��$;$;$8�’��$#’�<�$�;��#��’‘�$��$ �ee’‘$ a’;���’$$ 8�’�;�����#’�<���#��’‘�$ �ee’’ a’;���’;�a �’��#�’$���’‘��a$8�’�;�����$e#’�<��8�#��’‘�$�$ �ee’‘$ a’;���’;e� a;��’;e� ;�������������������������������������������������������

…so… million dollar question - did you ever get around this or did you give up?

Of course as soon as I ask I find what it was.

The cactus micro v2 does not come with the AT firmware anymore. It comes with the espduino firmware.

Using this version of esptool:

and using the programming sketch from: April Brother Wiki

allowed me to reflash the firmware.