TL;DR: a little PHP app running on AWS Lambda that:
- receive data from the Sense Peanut App running on iOS or Android
- save them in DynamoDB & InfluxDB
- and provide a simple API to read them
By the end of 2015 the french Sense startup launched some small connected devices and among them there were one to gather temperature: the Thermo Peanut. It gather the temperature and send it to a mobile app using Bluetooth. The app send these data to a server and you got some nice charts about temperature in return.
Late 2017 the startup is in liquidation. By the beginning of 2018 their servers became down for good. The app can still got the current temperature but charts are dead. And the app always try to send data to the server, killing the phone's battery.
I wasn't able to get a chance to read data from these connected devices using Bluetooth so I started looking at catching request from the app using a proxy.
I end up building that little PHP app to gather data and be able to retrieve them later.
As their servers are dead you won't be able to associate it to your phone. And yes we can still found website which sells them...
That project targets people who don't want to throw their thermo peanut away and who still have the app installed on a phone (which might stay at home all the time).
- a thermo peanut
- a phone with the Sense Peanut App installed
- a running instance of InfluxDB (on an EC2 for example)
- a proxy to redirect traffic from the app (Charles proxy running on Raspberry Pi for example)
- the serverless framework installed globally
- an AWS account with AWS credentials defined
-
Install deps
composer install -o
-
You'll need information from your thermo peanut. The most important one is its MAC address (something like
00:0A:95:9D:68:16
). You can find it when you'll enable your proxy.Create the init file and then update
init_db.yml
with the MAC address.cp init_db.yml.dist init_db.yml
-
Define information about InfluxDB (user & pass can be empty):
cp .env.dist .env
-
Deploy to your AWS account
serverless deploy --verbose
-
Once deployed you'll have a dump inside the console with information about URLs of the API like
Service Information service: thermo-proxy stage: dev region: eu-west-1 stack: thermo-proxy-dev resources: 26 api keys: None endpoints: POST - https://XXXXXXX.execute-api.eu-west-1.amazonaws.com/dev/peanut/api/v1/peanuts/{mac}/events GET - https://XXXXXXX.execute-api.eu-west-1.amazonaws.com/dev/thermo/{mac}/detail GET - https://XXXXXXX.execute-api.eu-west-1.amazonaws.com/dev/thermo/list GET - https://XXXXXXX.execute-api.eu-west-1.amazonaws.com/dev/thermo/init functions: api: thermo-proxy-dev-api layers: None
-
Init the DynamoDB table with data from
init_db.yml
(define at step 2) by browsing tohttps://XXXXXXX.execute-api.eu-west-1.amazonaws.com/dev/thermo/init
(from the list above)
-
Run DynamoDB locally using Docker
docker run -p 8000:8000 amazon/dynamodb-local
-
Run InfluxDB locally using Docker
docker run -p 8086:8086 influxdb
-
Launch the app
php -S localhost:8888 -t src src/App.php
-
Init the DynamoDB table by browsing to
http://localhost:8888/thermo/init
Now that the server is running, here are the endpoints available:
URL | Description | Response sample |
---|---|---|
/thermo/list |
Return the list of your devices (previously inserted during the installation process) | sample response |
/00:0A:95:9D:68:16/detail |
Return all information about the peanut | sample response |
I'm using Charles to setup the proxy because I wasn't able to properly run a proxy to do the same job. I tried few solutions without success (ssl-proxy, pound, mitmproxy and hiproxy to name a few). I often end up got nothing form the app after their first CONNECT
request... 🤔
The phone app try to connect to a server at this address https://app-00.sen.se:443
which means you have to redirect traffic to the API url on AWS.
So I setup a Map Remote in Charles with these information:
Then I defined the proxy in the Wifi setting of the phone which runs the Sense Peanut App and I started to receive the data (all the way back from 2018, wow).
Everything is now running on Raspberry Pi Zero on the same network as the phone which runs the Sense Peanut App ✨