My adventures with a Raspberry Pi and Arduino programming

I’ve been playing around with a great SD card logging unit from Hobby Tronics. This is a slightly improved version (and cheaper!) of the SparkFun OpenLog unit.

Software Serial has failed me on this piece though. You absolutely must use the standard hardware serial (Serial.println() ) functions in order to not lose data. Even with large multi-second delays and very little information being transferred, the Arduino Software Serial library failed to keep up.

This is unusual, as I’ve found the Software Serial library very reliable for use with GPS and 3DR radios’ serial interfaces.

I’ve successfully used the setup() routine to specify the file I want to save to. This required a bit of hackery. To send a Ctrl+Z character in Arduino (required for setting up the open log in command mode) you need to do the following in code:-

 Serial.print((char)0x1A); // Ctrl + z
 Serial.print((char)0x1A);
 Serial.print((char)0x1A);
 delay(1000);
 Serial.println("append " + file); // tell open log to append to a named file (file created if it doesn't exist)
 delay(1000);
 logGpx(file,team,now); // my customised logging setup function

Those delay() calls probably aren’t strictly required, but they don’t slow down my app either.

Note that char 0x1A is a hexadecimal number for ASCII character 26 (the A is the 10th character in a sequence, the 1 in the second column means 1×16 (base 16), thus 10 + 16, which is character code 26. ASCII character 26 is the same as Ctrl+Z in a terminal in Windows CoolTerm, which is the required character for entering and leaving command mode in OpenLog.

I’m using the XML based GPX format to write updates. In future I’m going to hook this up to a GPS, so it makes sense to use this format rather than NMEA as it can easily be read by online and desktop tools. You could use KML instead (Google Earth format).

I wonder how much current this little device draws?…

Power usage of just the memory card (doesn’t include the Arduino itself):-

  • During command mode, up to 12mA
  • During normal standby operation, 1.57 mA
  • During writing data, anywhere from 6.5 to 11.5 mA, averaging approx 7.8mA
Advertisements

Just a quick list for my own needs…

Things already done:-

  • Proven transmitter sends valid GPS tracking data to receiver on computer
  • Built prototype transmitter and tested in the field
  • Integrated GPS, 3DR radio, Li-po charger, Li-po battery, Arduino solderable breadboard in to an enclosure
  • Tested power saving mode (7 – 15 days charge possible!)
  • Created very basic symmetric cryptography routines

Things to do next:-

  • Get route logging software working, preferably with GPX file output (OpenLogger on HobbyTronics ArduLogger platform with micro SD card)
  • Range test air to ground module outside on maximum power settings, continuous transmit
  • Investigate 3DR circuit to see if its possible to make own PCB cheaper (and integrate whole device in one half eurocard PCB)
  • Get LCD display working on protoboard
  • Get Joystick working for basic menu items on same protoboard
  • Test multiple transmitters with one receiver (including testing using ‘air’ unit for receiver, and receiving multiple signals on same receiver)
    • If can’t use air module, use usb to serial circuit for ground module (might be fun to try anyway…)
  • Test 3DR radio LBT (Listen Before Transmit) mode
  • Test encrypted messaging
  • Develop own binary format for messaging (C language struct?)

Recent purchases…

I’ve made a couple of recent purchases after considering the full scope of my project.

Firstly I’ve bought another SparkFun 16×2 LCD module, and this time I won’t ruin it with a soldering iron by accident!!!

This LCD will be used in the D of E supervisor’s receiver module. I’ve also developed a user interface and set of menus so you can navigate through and track multiple teams, find your own position, edit settings, and even navigate to a selected team. (distance, bearing).

In order to drive this though I had to use some sort of interface. Several small buttons seemed a bit fiddly to add to the box, so I’ve opted for a PlayStation controller like Joystick! I can mount this on the project box next to the LCD. If you push this joystick down it also acts like a selection button, so I have left to right, and up to down navigation, and a selection button. Just like a standard modern GPS unit (but at a fraction of the cost).

Interestingly, SparkFun have stopped selling the black project box, now instead selling a clear one. That’s pretty awesome from a show-and-tell perspective! I can now show off the project, and see the power LEDs through the case. No need to drill LED holes that may leak in water.

I’ve also decided to buy a couple of micro SD interface cards – a ArduLogger device from a local supplier, but with the SparkFun OpenLogger software installed. This software is a bit more flexible, allowing you to name multiple files and either replace their content or append new content. Perfect for a receiver tracking multiple teams – you can have a GPX file for each day for each team. Great! I’ll also fit this on the transmitter so I can check the teams actual route later if they go out of signal line of sight. Not that I don’t trust them…

I also decided against bluetooth for a couple of reasons. Firstly, more complexity, space, and power usage for a very limited ‘download’ mode at the end of a walk. Also because I have a whopping 433MHz module already with a high baud rate! May as well re-use that to request and force an upload of an entire set of logs. They’re only a few KB for a day, so won’t take long at all to transmit.

Having two transceivers also brings the tantalising prospect of sending and receiving messages. A future ‘posh’ version of the transmitter may be a bigger battery, and LCD screen, and another joystick – so the team can send progress reports and receive information from their supervisors. E.g. ‘get off the mountain – crazy weather coming!’

I’ve also found a cheap supplier in Singapore for my Arduino Mega boards. More on that in another post. They’re approx GBP 1.80 each! Great if you want to make a lot of modules.

For my next trick I’ll use a Dremel to cut holes in my project case so I can mount the components. More to follow!…

There are many ways to save power on the Arduino board itself. I summarise these with power consumption numbers…

Read the rest of this entry »

Here’s some radio project pics for you…

gpstxrx-part-assembled

The first one, above, shows the partly soldered project. You can see the battery plug (top right of red solderable breadboard) which will go to my LiPo recharger circuit. You also see the 3DR radio airside module (left) and the mini GP-635T GPS unit (centre).

The aerial you see is the one that comes with the project. This is a WiFi aerial so will be getting replaced. Just waiting on a 433MHz compatible antenna to arrive.

gpstxrx-projectbox

Here you see the project box layout. To the bottom of the picture is the bottom half of the project box. You see the GPS unit in the top part so its antenna doesn’t have a clouded view of the sky.

You also see the battery in the top half. This will be plugged in to the LiPo charging circuit (red, bottom picture, right hand side), which will also have a power cable going to the solderable mini breadboard with the Arduino mounted. (bottom left).

Again the radio (this time the ground side usb module) is mounted at the bottom. I’m investigating whether a short adapter circuit can be used to make use of the ground side module. Ideally I want a UART module like the airside one, but suppliers of the full pair of units give you one of each. (For about GBP 30).

The embedded SoC radio circuit though costs only GBP 2.62 from Mouser!!! So it may work out cheaper to take this, and the open source 3DR radio schematics (zip), and build my own UART on a PCB with this chip mounted.

Design rethinking

Something I’ve noticed is that the extra vertical pins on the Arduino (A4-A7) only just fit in the project box. This is without the non-permanent header block from the first image. I’ll remove the 4 extra analog pins as I’m no longer using them. This will mean I don’t have to solder the Arduino entirely to the breadboard – leaving it removable for use in other projects. (You can see the height of the Arduino in the top image because I use a header block to mount it.)

I may also remove the barrel jack from the LiPo charger to remove the possibility of someone plugging in both this and the USB cable!

I also need to check if the LiPo circuit has a voltage regulator. If so I’ll wire the output directly to the VCC rather than the RAW line of the Arduino. The Arduino’s voltage regulator is well known for being power hungry, so removing this will help overall power consumption.

I’ve toyed with the idea of modifying the LiPo charger to be a 1-2 Amp charger, but most USB sockets don’t support above 500mA so I think its easier to just make people wait 4 hours to recharge the battery and keep the power lower.

In the future I’d like to add a way to download an activity log. I may develop a Bluetooth app for this – but for now I’m happy with a live view of data.

I’ve now employed a bunch of tricks to reduce power consumption. Here’s what I’d done…

Read the rest of this entry »

A few interesting things I’ve learned that you won’t find in any manual or tutorial elsewhere…

Read the rest of this entry »