My 32bits ATSAM node project
This is a project in progress. So I post here if I need to ask for some help (and I think this will be the case).
First, thx to @tbowmo for his work on 32bit GW
And thx to Sparkfun, Adafruit etc.. for all their work
I would like to introduce to you : M.and Ms Sam&LoraLip and their baby child
A board with a 32bit Atmel Atsamd21e17 (128k, e18 is 256k) and Lora (Long range RFM95W, but there is also a nrf24 smd footprint), with Lipo Charger. And two proto childboard.
Left top : M.&Ms Lip the mainboard
Right top : W(H)eather childboard, nice sensors for meteo
Left bottom : Adafruit Feather M0
Right bottom : Chi-Mote, (humm missing inspiration..) a childboard I have made for the Feather. For gesture and 3d control with rgb feedback. Sort of wiimote but smaller with gesture..my Chi in this one
Specs a little bit below;
So As you can see I have been inspired by Adafruit Feather M0. No advertisement here It was out of stock so I assembled one. First, to be sure to have a 32bit board (atsam based) which works. And finally, because I wanted to have a simple lipo capable board. But that was not enough..more things.
- I keep lipo + usb from Adafruit (as it's a charger, so it's nice to have usb on this one). Usb can be used to upload sketch as native usb.
- here it's 32pins TQFP ATSAMD21E16/17/18, I bought an E17 128k (on Adafruit, it's a nice big 44pins VQFN G18 family, first time for me, thx to my reflow). E17/18 cheaper compared to G18. If I would like to use L picopower family, I just need to swap 2-3pins.
And I added:
- footprint for usb filtering on +5v and shield
- footprint for fuse
- eeprom in case
- rgb led
- footprint for Nrf24 smd, RFM95W (not received yet), RFM69HCW (pincompatible with RFM95W if I'm right)
- for RFM95W, wire style antenna or connector
- MYSX connector (maybe I will reduce it)
I have made two child boards
- Weather optional (or not!) sensors : opt3001 for light, veml6070 for UV, SI7021 temperature/humidity, BME 280 temperature/humidity/pressure (in case I use this one I don't need si7021 of course), there is also AS3935 for Lightning detection. + switchable battery voltage sensor
- For the mote : RGB led, APDS9960 for proximity&gesture, 6DOF LSM6DS3 (6DOF is enough for what I want to do but maybe a better/expensive MEMS could be fun...)
Ok you really are cool guys if you are still reading. Now the pics:
Nrf radio style
Long range RFM95 style
Weather child board on mainboard
Assembled (no radio soldered, still doing basic tests), weather not assembled
Chi-Mote for MYSX connector (I will add an IR led as I have enough space, more fun)
And Chi-Mote for Feather, on top of it no radio soldered yet.
With a small lipo and humm..wireless charging, more Chi
And a very short video of my kungfu gizmo Gesture part is buggy for the moment so not activated and on the 6dof I only use single/double tap. Connected on a nano. but fixed on the wall, or few mobile in the house, very cool.
- the feather I assembled works ok. bootloader ok, and blinkled in arduino ide ok
- weather not tested yet, Chi-mote, all is good except gesture (I suspect power+infinite loop in lib!). Add an ir led
- my mainboard: sam-ba bootloader for ATSAMD21E17 well sent with jtag in Atmel studio, but I get a no device connected on comport in arduino. I am investigating if it comes from boards.txt ..
Few things to improve on mapping part
Certainly more things to say..but that's ok for today! I'm enough happy.
Thx for you interest and feedback.
See you soon
@scalz I'm impressed. It's people like you who make the difference!
Very good job ! I will be happy when I will able to do 10% of your work
thx guys, that's really kind comments
I hope to fix my small bug about upload in arduino ide, to share then. I don't know yet where it comes from.. I need to investigate as it's a little bit different compared to Arduino Zero because I'm using a "smaller" pincount chip so maybe it needs some tune.
In other hand, I am already dreaming of a @Tekka's atsam ota bootloader lol ! few second upload with jlink with only two pins and then ota. But in other hand it's nice when usb is there, to have the native usb in ide so I really need to fix this (certainly software related..).
Tests I did to try to understand:
- with first homemade board ATSAMD21G: upload of adafruit bootloader (which I think is derived from the Zero or maybe the same). My device is then detected in Windows as an Adafruit device Virtual com port. In ide, I choose adafruit Feather board, upload sketch. Yeah! If I choose Zero board, it uploads too! And in Windows, my device is then detected as a Zero device. I can do inverse. So it's interchangeable but not recommanded because you need to take care about io mapping of boards, variant cpp...
- with my second board, ATSAMD21E : I use bossa bootloader from atmel dedicated for this chip, BOSSA programming device comport well detected in windows on COM14 for instance, but I get a "no device found on comport14" when I try to upload in arduino ide..I tried with others bootloader, still the same..of course!
If you are curious, Bossa is sort of avrdude which is included in arduino ide for atsam. I have multiple programmer, but for the moment I am using a Segger OB which is the same as Atmel ICE (I had luck to find this programmer, genuine, discounted!)
wew! I have just got the blink led sketch uploaded from arduino ide on my custom D21E. great! now I need to check my board and io mapping. cool cool
cool I have my Chi mote working on my custom board, after few changes in libs regarding atsam
Next step, mysensors libs and I can't wait to receive my lora module to give a try. I have nrf smd footprint but no more in stock, so impatient that I'm thinking to unsolder one on another board
But RFM95W is not supported by MySensors yet? (at least I think that it doesn't.. Haven't seen a git commit for it in the library). So are you going to use another library for that module?
I'm discovering the joy of new chip and the stuff about sam bootloader, arduinocore, board/pin def. I have not digged so much but still good to know how things are connected.
Hopefully I found a bootloader+board def which fits almost with my pinout, but spi part which is not in same order. Cool this story of configurable sercoms..but that still needs to adapt a little bit pins define in variants...does I understand right? Sometimes it's very confusing all this stuff of pins define between boards etc..
I have not tested the spi part yet, but very soon I will wire at least rfm69 and nrf. I have not received my Lora. I have looked at multiple libs, don't know yet which one. My first choice may be not radiohead, I will try it sure, but I would like something "standalone". I will start with basic examples! and then "standalone" will be easier to add to mysensors transport stuff I guess (my lazy way..) But don't know yet when I would like to finish what I have started on rfm69 part.
Do the RFM95 use the same footprint as RFM69?
About the SPI, you might need to hack the standard arduino SPI driver a bit (I have done this for the GW module..), depending on how you have wired your sercom/SPI unit..
yes I have found where to hack spi pins...will give a try this evening I think. If I can't get it to work may I ask you ?
To resume a little bit about rfm, there are:
- RFM69HW : High power version (best known version)
- RFM69W : non-high Power version, pincompatible with RFM69HW
- RFM69CW : other non-high power version too, but not pincompatible with those above W
- RFM69HCW : High Power version again. But we could think this one is pincompatible with the simple CW. That's not the case! This one is pincompatible with RFM95W!
All these RFM69 are software compatible. Very confusing, isn't it? but more options!
As you can see, I have made this board for long range fun, and personal challenge With RFM69 high power version and RFM95 (outdoor, and that's why there is the lipo charger maybe basic solar app) .
But in case, I would like to have a lower power radio, I added nrf footprint. I couldn't add another low power RFM69! I will certainly have two version of this board: one long range, another RFM69CW+nrf maybe without lipo charger this time..
hi. I was just thinking that I didn't give news about my mux!
in case, I guess you already know it, but that helped me so I share:
I tried the howto for i2c too. worked nice.
so no need to hack the lib in my case. (even if I have rerouted my board to fit mattair pindefinition which I prefer because "real" pin number match to pin number in arduino..matter of taste).
Perhaps hacking libs could give a little bit more freedom but that's already pretty flexible like this, cool
I have not had lot of time for my lora modules yet, still on my desk, pfff
Amazing work again. I really love the name Chi-mote
I am really beginning to like this little 32bit chip.. mux flexibility, enough memory, the price. Even if I was planning to use my jtag smd pins with pogo, usb cdc is cool for direct connection programming and uploading is really fast!
the only downside is, I was aware, it require to make changes in sensors libs , to add constructors for platforms defines+modifying a little bit our common wire, spi, interrupt functions. For testings purpose it's ok, but I should fork these libs to add my changes...so much work!!! for the moment I have tested/modified only few libs like SI7021, ambiant light sensors, apds9960, 9930, mems, neopixel etc., still local..
I will now post my design files soon for those who would like to try I just need to make few tests/minor decisions on my design.
When I see those price of released lora boards...wow, sure could be better but I'm happy with my board. I thought that I could try to make my own rfm95 circuit onboard, could be cheaper and a little bit smaller. But generally, I prefer to use a FCC compliant module, especially for lora...and so I can have footprint for an other radio, more modular, who said useless lol!
Most of these sensors that you mention (si7021 etc) they are I2C, so only the base I2C driver needs to be adapted, so what changes are necessary for (for example) SI7021 to get working on the atsamd?
@tbowmo you're right, it's because of a wrong mapping!! If I only use something like Wire.begin(sda,scl) it didn't worked well for me. Of course this could be fixed in variant, sercom.. etc but I didn't want to change this or create mine (I prefer to stick an existing/well updated one). So the only thing I need, to "remap" my pins, is :
#include "wiring_private.h" // pinPeripheral() function #if defined(MY_ATSAMBOARD) TwoWire newWire(&sercom3, 22, 23); #endif
And in setup, or in libs..
#if defined(MY_ATSAMBOARD) newWire.begin(); // Assign pins 13 & 11 to SERCOM functionality pinPeripheral(22, PIO_SERCOM); pinPeripheral(23, PIO_SERCOM); #else Wire.begin(); #endif
And then I need to use my newWire object instead of common Wire.
rough example, not beautiful, that should be better done I know..but it's rough test and for my bad mapping. When remapped to the right pindef boards, that should work like it should do..
Hum..I will give another try to Wire.begin(x,y) to see, you make me not sure now...
In other hand, how libs manage if someone want to play with another i2c? Wire function and begin() are hardcoded in libs, so it use default i2c bus mapping...
I've made "local" copies of SPI / TwoWire libraries (Local as in mysensors specific), which are added to the SAMD GW hw profile in Arduino.
So people just choose the correct board, and everything is setup for them
@tbowmo cool, thx I forgot that's included in mysensors git! I will look at your work and diffcheck to see your changes. I will try this for this rev at least even if it's working with ugly cheat
My next rev follow mattairtech board. So I won't need this, and no arduinocore files versioncheck . I let others doing this. So I will just choose the right hardware in ide and that should work like a Zero. This is actually what I am doing but I am cheating to fix my wrong mapping.
Thx for your feedbacks. I agree with you, each test/learning session takes a lot of time but I will try your way and report; the way I started to look but found a trick
cool, finally I have made my board definition
maybe I was missing something during my previous attempt as it was not so hard..
works nice like you said
look at this upload speed!! not a big upload (just an example test sketch) but crazy cool
Very interesting thread!
I hope arduino project (and any child projects) will move to more fast hardware in near future!