The wind station has gone through its third and hopefully final R&D iteration, and I think now it's alright - but it was a bit of an odyssey to get to this point.

After coming back from Austria at the end of February I started investigating all the problems with the earlier version; I found out that
"Kun's Design" SIM300 board was doing pretty weird things to the TTL serial (running a MAX232 at only 4V didn't work overly well, especially as the TTL levels were generated by running through the MAX twice, from 3V to 15V and back to 5V) and that it would completely stop communicating every now and then. Besides that I had occasional trouble with the 32kHz quartz (for the PIC real-time clock) not starting at all - maybe because of the lowish operating voltage? It happened both on the breadboard as well as the finished board, so my less-than-great protoboard setup shouldn't have been a factor.

Anyway, I decided to invest a bit more of my money into a better GSM/GPRS board: the icomsat v1.1 board looked good and I ordered one from squarebit.

The icomsat uses a SIM900, which has the advantage of being a bit more modern and with fewer weird voltage levels than the SIM300 (all its logic is 2.8V); it's designed as a shield for arduinos which is nevertheless mostly useful for my PIC-based setup. The icomsat also lets you access almost all interesting SIM900 signals, so I could implement a few new features for improved robustness. On the downside I had to redo the schematic somewhat, and build a completely new board for the PIC.

The icomsat board has a few suboptimal aspects, too - and I hope that iteadstudio addresses those in a future revision.

  • The SIM900 status pin isn't accessible.

    This makes determining the power state of the board quite tedious (even more so as the power signal timing is almost identical for both switching on and off).

    One choice would be to send it an AT on the serial side and check if you get anything back (modulo ATE0, of course). Less than ideal if you want to use transparent comms mode, for example.

    The other choice is to scrutinize one of the other, accessible signals and see whether it's any good to indicate on/off state. I did that, and found that DTR is close to perfect for this purpose: when the SIM900 is off, the signal is around 1.5..1.8V. When it's on, the SIM900 pulls it up to 2.8V, and the client is then supposed to control it (ie. leave it high or pull it low). 2.8V is sufficient as TTL 'HI' but 1.5V isn't much good for a TTL 'LO' signal, so I used the PIC's analog comparator to read it.

  • The sim card holder is extremely cheap and fragile; mine wouldn't reliably make contact with the sim card without some pressure on it.

  • The icomsat gets its power from the arduino 5V pin instead of the VIN pin.

    The arduinos have onboard voltage regulators to produce stabilized 5V, but it's just a linear regulator which wastes lots of energy and gets quite hot. The SIM900 needs up to 2A of current for brief bursts every few seconds, which makes using the arduino's regulator very inefficient. However, the 'real' higher-voltage input is accessible on the shield connectors on the VIN pin.

    The icomsat needs to down-convert any input voltage anyway, so whether it uses 5V or a higher VIN voltage doesn't matter for its power supply. Ideally the icomsat would let the user choose whether to use the 5V input or VIN (this would require minor changes to the circuits for pulling up the 2.8V signals to TTL level (ie. TX, RX, RI) but not much else).

    But why is this relevant for me, not using an arduino? Well, I've got a 12V battery as power source, so having the icomsat regulate that down in one go and powering the PIC off this lower voltage would be very nice (and the older version with the SIM300 board did precisely that).

    But the icomsat doesn't expose either VBAT or VDDEXT pins, so I can't get power from it (4V rsp. 2.8V). (Simply feeding the icomsat 12V on the 5V input also doesn't work because the TTL level signals would then be at 12V instead of 5V).

    So for the mk3 board I had to add another voltage regulator, a switch-mode LM2596-based dinky little board that I set to generate 5V. The PIC runs off that, and the icomsat down-converts it further - not absolutely ideal wrt. efficiency but not too bad.

The schematic for the new board looks similar to the old one, except for the following changes: no more in-circuit programming, and more signals from the SIM900 are used. The ICSP pins are needed for the real-time clock oscillator, and after the previous hassle with this I opted for a simpler, more foolproof setup (and the PIC is not soldered in but socketed anyway). On the PIC side all the signals are routed to the arduino shield connectors (ignoring the arduino definitions for all shield pins except power), and on the icomsat board I use a few jumper wires to plumb in the remaining non-shield-signals. The new signals are DTR for power state, CTS and RTS for serial flow control and RI for reset-by-phone.

 wind station mk3 schematic wind station mk3 layout

Construction-wise I've learned my lesson, too: goodbye protoboard, this time I used stripboard and Eagle to create a decent layout with a minimal number of jumpers to solder. The necessary strip breaks I made with a 1.5mm drill bit and a cordless drill. The RJ11 socket doesn't conform to the normal 2.54mm grid, so I used jumper wires for it.

 board plan stripboard drilling construction construction

I'm quite pleased with the result; it looks a lot cleaner than mk1 and 2, and even with the jumpers it was still less hassle than doing a toner-transfer PCB.

 shield testing testing housing

On the software side I've gone back to KISS and maximum simplicity. The PIC fires up, checks the SIM900 and if required powers it up and initializes it; after that it takes readings every second and transmits them as a single UDP packet once every 5 seconds. Before every transmission the SIM900 is checked and powered up if needed. That's it, no timed restarts or resets, no analyzing of any serial responses from the SIM900, nada.

One new item is the reset-by-phone capability: call the unit's number, and the SIM900 asserts the ring indicator signal, which is tied to the PIC interrupt pin; at that point the PIC interrupts its usual work, powers down the SIM900 and then completey resets itself via the watchdog timer. Neat bit: the call never completes and hence doesn't cost anything.

I'm not going to write anything about all the testing that I've put the mk3 wind station through until the gremlins were gone, but I'll mention a few choice findings that might come handy for anybody who plans to use a SIM900:

  • RTS/CTS flow control works if and only if you pull DTR low and have AT&D1 in your SIM900's profile.

    The SIM900 AT command manual doesn't mention any of these aspects. With &D0 ('ignore DTR') I couldn't get the SIM900 to use CTS, and the crucial info about also having to pull DTR low I only found in a footnote of the SIM900 Serial Port Application Note.

    Testing the SIM900 power status via DTR like I do also means that I can't use the sleep mode/CSCLK stuff: I need to let DTR float to read its voltage (SIM900 on or off), then pull it low again to talk. With sleep mode enabled that floating DTR triggers the sleep, and leaving sleep mode takes a fair bit of time.

  • Some common unsolicited response codes trigger the ring indicator signal, which could lead to a reset loop if you implement reset-by-phone: you get a call, decide to reset and on restart the SIM900 gives you one of these URCs and another RI and you reset and...

    Using AT+CFGRI=1 disables the URC-triggers-RI behaviour.

As always here is the source code for everything (licence: gpl, also as usual), and finally a few photos of the new installation (which you can observe in action on the CHGC website).

 wind station - box of goodies wind station - box of goodies wind station - finished wind station - finished
Update (Fri 20.09.2013 15:55):

I've built another wind station for the CHGC, for our launch at Mt. Tamborine, and revised the software somewhat:

  • The new station firmware checks whether sending the wind readings via GPRS has worked, and if not resets the whole station after a configurable number of consecutive failures. That makes the setup much more robust, as most of the faults that I've encountered so far were temporary network outages - which the old firmware didn't detect, so my external monitoring system had to ring the station to reset it.

  • The wind receiver daemon now supports multiple stations (but still with just one sqlite database). The configuration for this is at the top of the wind-receiver file in the source tarball.

The electrical setup hasn't changed (hence the schematic and component layout haven't either). Here is the updated source tarball.

Here are a few pictures of the new station:

 tambo wind station plus housing tambo station installed tambo station installed
Update (Sat 28.03.2015 17:51):

the two wind stations have now run continuously for two years (a few months less for the tambo one), with almost zero downtime and no maintenance.

i'm inclined to consider this project a success :-) and have put the stuff on github for good measure.

[ published on Fri 26.04.2013 16:07 | filed in interests/tinkering | ]
Debian Silver Server
© Alexander Zangerl