DevDuino Sensor Node – Part 1 – Programming the DevDuino

Do you like this post? Writing posts, developing libraries and programming online font creators is actually hard work. I order most of my electronics from a Chinese website called Banggood. It is save and the items usually arrive in good quality. With every order you do there by following this link you are supporting the blog. Thank you!

It took me far too long to get this working, but I finally did it: a small Arduino compatible board called “DevDuino” running on a CR2032 cell battery is sending temperature and battery voltage over the air to another Arduino board which records it. Sounds easy, doesn’t it? Well, it depends…:

  • which Arduino are you using?
  • how good is the documentation of the DevDuino?
  • what wires do you have available?
  • Do you have a ISP programmer for the DevDuino?
Looking back I learned a lot about electronics but it also cost me a lot of time and maybe this blog post can save you some. But first things first. 

Programming the DevDuino

A while back I ordered the DevDuino V1.2 from Seeedstudio and I was very excited when it arrived. Maybe I should have read the (probably with Google Translate) translated Wiki page here to realize that I needed something to program the DevDuino. One way is using an In-System-Programmer (or short ISP) which can be a dedicated tool or a simple Arduino board. I checked out my Arduino box and found a Duemilanove compatible board and a Leonardo compatible board. I decided to use the Leonardo as ISP which was the first mistake: the Leonardo has some specialties which you have to be aware of or you will waste a lot of time. To turn a regular Arduino board into an ISP you’ll have to upload a special sketch to it, then swith all the settings to the board you want to program and pick “Arduino as ISP” from the programmer menu. Then you’ll have to connect the target platform with your ISP-Arduino, which might require some female-female jumpers. To upload a sketch to your target platform (like the DevDuino in my case) you hold down Shift while pressing the “Upload” button in the Arduino IDE. This page describes the process for “regular” Arduino boards pretty well. If you happen to use a Leonardo as ISP, then this page might help you. In short: you’ll have to adapt the sketch you upload to your ISP by changing some pin definitions which are different for the Leonardo.
The wiring might also be different:
Source: Freetronics

So now you can send sketches to your DevDuino! If you want to save battery lifetime you can (and possibly should) adapt the settings for your target board. The DevDuino Wiki suggests to add the following lines to your boards.txt (on Mac OS X this might be here: 

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt):

s328o1.name=Sensor328p (int1MHz, 1.8V)

s328o1.upload.protocol=arduino
s328o1.upload.maximum_size=30720
s328o1.upload.speed=19200

s328o1.bootloader.low_fuses=0x62
s328o1.bootloader.high_fuses=0xda
s328o1.bootloader.extended_fuses=0x06
s328o1.bootloader.path=atmega

s328o1.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex

#s328o8.bootloader.file=ATmegaBOOT_168_atmega328.hex

s328o1.bootloader.unlock_bits=0x3F
s328o1.bootloader.lock_bits=0x0F

s328o1.build.mcu=atmega328p
s328o1.build.f_cpu=1000000L
s328o1.build.core=arduino
s328o1.build.variant=standard

Then close the IDE and re-open it. Under Tools > Boards you can find now a board called “Sensor328p (int1MHz, 1.8V)”. Select it. I believe you have to update the bootloader on the DevDuino

Now lets test the DevDuino with a minimal sketch:

int led = 9;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

which will make the built-in LED blink on the DevDuino. To upload this sketch to the DevDuino make sure it is attached correctly to be programmed as shown above. Switch to the correct programmer on Tools > Programmer > Arduino as ISP (or similar, if you use a special board like Leonardo). Then select File > Upload using Programmer or hold the Shift key while pressing the Upload button of your sketch. After the status turns to “Done Uploading..” the LED on the DevDuino should start blinking…

This was part 1 of the DevDuino tutorial. Part 2 will go into more details…

Links:

Posted by squix78

11 comments

  1. Hi Dani,
    My matrixes arrived yesterday and I've been playing with them on an Arduino just to make sure I built them properly. Everything checks out.
    Now I'm trying to move to the ESP and I'm having compile problems.
    I tried Arduino 1.6.4 and I get these errors (I hope they'll copy in here…)

    Arduino: 1.6.4 (Windows 8.1), Board: "Generic ESP8266 Module, 80 MHz, 115200, 512K (64K SPIFFS)"

    Build options changed, rebuilding all

    C:Program FilesArduinolibrariesMAX7219LedMatrix-masterLedMatrix.cpp: In member function 'void LedMatrix::scrollTextLeft()':
    C:Program FilesArduinolibrariesMAX7219LedMatrix-masterLedMatrix.cpp:122:18: error: ambiguous overload for 'operator=' (operand types are 'String' and 'int')
    myNextText = NULL;
    ^
    C:Program FilesArduinolibrariesMAX7219LedMatrix-masterLedMatrix.cpp:122:18: note: candidates are:
    In file included from C:UsersMichaelAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/Arduino.h:209:0,
    from C:UsersMichaelAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdelibrariesSPI/SPI.h:24,
    from C:Program FilesArduinolibrariesMAX7219LedMatrix-masterLedMatrix.cpp:2:
    C:UsersMichaelAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/WString.h:85:18: note: String& String::operator=(const String&)
    String & operator =(const String &rhs);
    ^
    C:UsersMichaelAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/WString.h:86:18: note: String& String::operator=(const char*)
    String & operator =(const char *cstr);
    ^
    C:UsersMichaelAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/WString.h:87:18: note: String& String::operator=(const __FlashStringHelper*)
    String & operator = (const __FlashStringHelper *str);
    ^
    C:UsersMichaelAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/WString.h:89:18: note: String& String::operator=(String&&)
    String & operator =(String &&rval);
    ^
    C:UsersMichaelAppDataRoamingArduino15packagesesp8266hardwareesp82661.6.4-628-g545ffdecoresesp8266/WString.h:90:18: note: String& String::operator=(StringSumHelper&&)
    String & operator =(StringSumHelper &&rval);
    ^
    Error compiling.

    This report would have more information with
    "Show verbose output during compilation"
    enabled in File > Preferences.

    I didn't do the verbose messages – would that help?
    Have you seen these kind of errors before?

  2. Hi Dani, I'm reza.

    Nice work!
    I can compile and upload to my ESP-12 but the Led Matrix doesn't show the word i want (just blinking and turn the leds randomly).
    I use DIN at GPIO13, CS at GPIO12, and CLK at GPIO14.
    Can you fixed the error please?
    Thanks

  3. My 8×8 (4 off) are already joined together as a unit and the letters scroll vertically. Basically I'm asking if I can alter the code to swing the matrix character map through 90 degrees. thanks
    John

  4. Brilliant programming – lots of features. Can even add a wifi access point server alongside to change the scrolling text. Also have rotated the font so that it could be viewed as a vertically scrolling display. One question, I cannot see, software-wise why it should not work for more than 8 modules – though cannot get it to work. I wonder if the power drain is too great. Will try a non-inverting 5V level shifter for my Wemos D1 R2. Thanks again Daniel.

    1. Hi David. That sounds interesting. How did you attach the 8 (and more) modules? All on the same I2C bus or on different pins? I also don’t see a reason why more shouldn’t work, except maybe for the memory. If you have separate instances of the display driver each allocates a part of the memory for buffering before writing to the display. It could be that you use all the available memory…
      Regards,
      Daniel

  5. Thanks for the code! Works great after a couple of tries. For those who tried to use the supplied AnimateText Arduino code and didn’t work, try including the font library that is bundled with it. For some reason it was left out.

    I also couldn’t define CS_PIN 2 to something else. I tried pin 12 (since it’s right next to pins 13 and 14) but didn’t seem to respond so I switched it back. Not sure if anyone has found the solution to this, but not a big deal.

Leave a Reply