Wednesday, 29 April 2020

Electronics assembly with Kicad and JLCPCB Assembly

I am shortly getting this assembled:



Thanks to JLCPCB Assembly.

Designed with Kicad  

A big thanks to all EEVBlog forum users and EEVBlog forum user "essele" who created this Kicad plugin for jlcpcb assembly which I have now forked to work with panelised boards

Also thanks to Flemming Frandsen for kicad-util which generated the pcb panelisation. I have forked this to work with Kicad-nightly.




Monday, 16 March 2020

Malenki-nano radio receiver and speed controller

Let's have a look at what I've been working on.

The Malenki-Nano is control module board for robot builders, intended for small robots of 150g or less, where weight and space are important.

Traditionally, a separate receiver and speed controller(s) were used. This is great but it means there are a lot of messy wires to get tangled / broken and take up space inside the robot. The integrated module reduces wiring and is lighter than a traditional rx / esc combination.

My module's specs are:
  • A PCB with radio module mounted on top, dimensions approx 30x20 mm
  • Overall height ~ 10mm (because of the very large crystal oscillator can on the radio, I cannot easily fix this)
  • Electronic speed controller: three channels of DC brushed motors @ 1.8A per channel maximum 
  • Power input - 1-2S lipo pack (minimum ~3.6V, maximum 8.4V)
  • Radio protocol: "AFHDS 2A" which is used by many cheap radios (e.g. those sold by Hobbyking)
  • Antenna: PCB trace "F" antenna (see picture) - seems to give a range of at least 20 metres indoors, which is enough for robot combat.
  • Auxilliary channels - 2x PWM output for other devices e.g. brushed ESC or servo.
  • (NO built-in BEC / 5v regulator; the device uses 3.3v internally)
  • Weight: < 4g excluding wires
 Pictures, or it didn't happen?


http://vectrex.org.uk/mark/back-01.png


Status:
* This module, pictured above, works in its current prototype, but there are a lot of changes I need to do, including swapping the motor driver chips and fixing a few minor problems with the pcb layout. 
I also need to test it with more different transmitters.

Availability:  

I may be able to make some of these boards available to purchase, later in the year 2020. Update: fill in this contact form if you are interested, and I will get back to you.



Wednesday, 1 January 2020

Renewable energy exaggeration

Every year (or more often) we see these "feel good" renewable energy stories such as:

https://news.sky.com/story/more-power-came-from-renewable-energy-than-fossil-fuels-in-uk-in-2019-11898806?dcmp=snt-sf-twitter

I'm not trying to single out Sky News, nor is it really "fake news".

Just somewhat optimistic exaggeration.

Forms of energy

In the UK, energy usage is approximately split three ways, for heating, transport and everything else.
Grid electricity is almost 100% "everything else". So today only about one third of our energy goes through the grid. 
Almost all of the heating and transport is fossil-fuel based, and that's changing only very slowly.
 So even if the grid was to be magically 100% carbon-free (or "renewable", but that's another story) then the other two-thirds would still be mostly fossil fuel.
As far as I can tell, people who haven't read David MacKay's book, usually forget this.
New houses are being built, mostly with gas boilers, which cannot run off renewable energy (NB: I know, biogas etc, is a thing, but not at scale).
 New vehicles are being built which cannot run off anything except fossil fuels.

Fake news or not?

No. The report is from National Grid, who don't monitor non-grid based energy. Heating was not mentioned at all, and transport was only mentioned for future planning.

What's the real story?

Really it should be "Fossil fuels still make 85% of UK's energy". (Or thereabouts)

This doesn't sound so encouraging.

But have a happy new year anyway.

Saturday, 28 December 2019

Reverse engineering the Flower Power app

"Flower Power" is an "internet connected" plant / soil monitoring device which was sold in 2016 by Parrot. The company subsequently decided to discontinue these products to concentrate on its better-known flying drone products.

We acquired some Flower Powers for an environmental study project.

How did it work?

A small low power, very clever monitoring device ( see Sylvia Wu's magnificent teardown ) monitors the environmental conditions, and logs them into a local non-volatile memory. It has a Bluetooth Low Energy (BLE) radio to communicate with smartphones.

Then periodically it synchronises with a smartphone app (available for Android and ios) to send the data up to a "cloud" internet server. The phone app doesn't need to connect to the sensor and the internet at the same time; it can buffer data and send them up later - which is useful if your plants are in a location where internet connection isn't available.

What's the problem?

Parrot have stopped supporting the devices and will switch off the (internet) API soon.

We still have working sensors and want to use them at least next year, maybe after.

There may also be more Flower Powers sitting in storage somewhere; those will become really useless if the API to update the firmware isn't available. I wanted to get the firmware before Parrot turn off their servers.

Reverse engineering


The Android app is a .apk file. I downloaded file from this "sideloading" site here:  


 - of course I don't know if this is the real, unmodified app (from "apkpure"), but it seems likely. I'm not going to load it on a real phone from here.

I extracted the files from .zip formats, and eventually found the "meat" of the application in the .dex files classes.dex classes2.dex and classes3.dex.

These are "Dalvik Executable" files, which are just packed in a different format to .jar - so I' used this utility "dex2jar"  to convert them into .jar

Then I used this Java Decompiler to extract the source code.

I was able to see that the app communicates with https://api-flower-power-pot.parrot.com - but it uses some weird authentication scheme.

Fortunately, the code https://github.com/growobservatory/MyData implements the authentication scheme for this API. 

The "secret" client id and client secret are also hard-coded in the Android app source code, so I was able to log in and call the APIs (and get the api token needed for authentication below).

Using this, I obtained the firmware download location:

wget -S  - 'https://api-flower-power-pot.parrot.com/sensor_data/v1/firmware_update/flower-power' --header="Authorization: Bearer myapitoken"

// Got API token by using MyData

// "flower-power" device
{
   "errors" : [],
   "firmware_version" : "2016-09-14_hawaii-2.0.3_hardware-config-MP",
   "user_config_version" : 39,
   "server_identifier" : "2.1.18 April 6th 2017",
   "firmware_update_url" : "http://hawaii2-web-service-prod-firmware.s3.amazonaws.com/2016-09-14_hawaii-2.0.3_hardware-config-MP.bin?1474470262",
   "garden_status_version" : 219
}

Then I could download (without authentication) the firmware image file.

What next?

Ultimately, if we have any new boxed Flower Powers, I will create an app which flashes the firmware image without using Parrot's cloud servers.

This should allow flashing the devices.

We can also call any of the APIs which the app uses, to get our data from the cloud, plus pictures, etc. (Grow Observatory's Getdata app does some of this)

To be continued... I have all the files downloaded. I suppose if Parrot's servers go away, it gets more interesting.

Also,  this NodeJS project claims it can talk to the Flower Power:

https://github.com/sandeepmistry/node-flower-power 

It also says it can update the firmware.