Home

Vodfaone NB-IOT, Fipy and AWS

Leave a comment

Timeline : 2-4 months on a occasional weekends

Having a sensor to sense things is one story, Having an on-field sensor is another story in itself. While powering up the sensor and weather proofing is not the intention of this blog post but sure they are the other aspects that one needs to address before moving to higher layer communications.

Growth In Green House – Problem is this Indian variant likes very specific Humidity and Temp and I have to measure Humidity/ Temperature/Ambient Light to know what is helping it. I got great
success only once out of 3 times of sowing

Issue – Have a sensor on Field, make sure it communicates itself to AWS IOT end platform. This is not that simple, that too without using high cost end products which abstracts everything from end-user. To put it in simple terms, you have a field or a farm which is quite away from your home and without a power resource, what would you do ?

Lora is one the most effective option that works for us, while I did setup a Gateway and end-node Lora Device, this post aims at something more simple without involving Lora, I will cover Lora in a different post

What is the Hardware used –

Vodafone NB-IOT – This particular service offering from Vodafone is really nice, to put in simple words, this service latches onto Vodafone or Vodafone partnered network and helps you reach a certain destination in the internet, its not designed for high amount of Data Transmission but for low transmission data rates.

Pycom – Fipy Module – https://pycom.io/product/fipy/ -> This module support NB-IOT/Lora/LTE/BLE/Wifi modes of communication. In this case, Vodafone offered SIM would go into this particular Module. Catch here is that Vodafone NB-IOT sim is only offered with Pycom modules and can only communicate to their site, before you ask about AWS, Pycom has integration with AWS which transmits to AWS IOT and AWS Timestream for further analysis

AWS – No brainer here. I used AWS timestream https://aws.amazon.com/timestream/ and AWS IoT core https://aws.amazon.com/iot/ to get the metrics onto the cloud

So what is Hosted Where ?

-> Grafana hosted in a Docker on a EC2 instance

-> Amazon Timestream gets all IOT data as Rule from AWS Lamda Function

-> Pycom has Pybytes which relays information onto AWS

Challenges :

From AWS standpoint, everything is as smooth as you could expect, Message comes onto AWS IOT , gets run by Lambda and then gets into Amazon Timestream

Challenge was Pycom Node, NB-IOT firmware instructions and flashing notes was not up to the mark, one thing that helped is their support channel public forum experts, I will write up Lora Integration with ThingsNetwork and Pycom and it was very easy for beginners

Cost for IOT : Zero, AWS offers everything for free tier, you could do all of this on free tier and it would not cost a penny if you remain in Free tier

Hardware – Imports into Ireland was VAT added and Vodafone NB-IOT subscription would cost depending on the package.

Conclusion –

Well things would be very very cheap if we have Lora Gateway and Lora WAN connectivity, obviously NB-IOT sims are data usage based so you can get lets say a value of moisture on the group against something aggressive like Micro-Climate metrics, catch is that deep-sleep implementation with Li-Ion batteries would last easily for couple of years even without having to invest in Small solar panels and relying on Solar.

AWS DeepLens and Telegram saving bird’s food and plants from my Dog!

Leave a comment

Weekend project after a while!. Not Long ago, I did mention that my cute Dog is responsible for destructing most of the wall and paper, when enquired pro’s said its part of puppy growing up and it still needs time.Along with Dog, I personally would love to feed and enjoy petting other species to be honest out of which birds and plants are major, there are earthworms and sea life but Dog is not a threat to them based on the placement.

Links

Git: https://github.com/yukthr/auts/tree/master/aws_deeplens

Credits: Some of the code block is picked up from : https://aws.amazon.com/blogs/machine-learning/building-a-smart-garage-door-opener-with-aws-deeplens-and-amazon-rekognition/

Tripod stand: https://www.amazon.co.uk/gp/product/B08FGSV9CZ/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1

Deeplens : https://www.amazon.co.uk/AWS-DeepLens-2nd-Generation-learning-enabled/dp/B07KYLSRZM/ref=sr_1_1?crid=36ZDKLZ7XF7Q3&dchild=1&keywords=deeplens&qid=1621074882&sprefix=deeplens%2Celectronics%2C156&sr=8-1

AWS DeepLens

https://aws.amazon.com/deeplens/ – Is ML/AI enabled camera which can be used at edge inferencing. Slipping down to my usual choice of words, this piece of equipment has an onboard camera , a Gpu , a Cpu and ubuntu host OS. Easily integrates with AWS and runs a local Lambda for inferencing, hence decisions are made on the device instead of reaching out to AWS to do the logic.

What is the problem!

There is a small garden at the rear of the house, its split in such a way that all 3 (My Dog, Plants, Birds) needs
to enjoy the space. 2/3 does not create a problem , 1/3 you know which one among them tries to kill and eat everything away.

Problem is that my Dog eats all edible plants and flowers, examples – Roses, Strawberries, Aloevera , Beans and destroyed Asparagus and Rose plant. On top of this, she scares the small birds which come to garden for the their allocated food in the morning hours mostly and then she tries to even eat that food!

Some suggestions – A bird stand/house, what I have seen is that Birds tend to like food on the ground rather than in a Bird house and the area where i Live is mostly windy all the time, so it ended up falling down even after a good amount of protection.

Love

Am painting a evil picture but trust me if its not for her, this lockdown period would have been misereable for both my wife and myself. Well that does not mean she can eat birds food.

What did Deeplens Do and how is that used ?

Project is real simple, Deeplens camera needs to do one thing, look at a designated area in the garden and see if Dog is in that space, if so just send an image or make a sound, I coded it to send an image as iteration 1

Setup:

I explored many options and finally settled that Telegram App is the best as the API support is awesome and sending images to Telegram BOT is real easy

Next, AWS provides with default templates to deploy ML/AI, but a little extension is needed

-> if it sees a dog, send the picture to s3
-> on s3 trigger, a lambda function will be run to send that S3 image to Telegram App

I have simplified this so that anyone trying to get some Handson should find it encouraging, you could do a lot of cool things with AWS IOT/ AWS Rekognition integrated with AWS Deeplens but thats not something feasible in a blog post

Below is the Architecture

AWS Deeplens Painpoints

  1. One painpoint is that if your turn off the device for any reason and turn it on, Deeplens wont go online and no activity can be noticied

aws_cam@AWSDeepLens:~$ sudo systemctl restart greengrassd.service –no-block -> This command helped me 9/10 ten times to repoll and bring it back online

  1. If you are new to Deeplens, a little experience with Lamda goes a long way , trust me.
  2. No models available for making this camera weather resistant, for my use case I can easily put it behind the Window glass, but if you are looking for a outdoor project, then power and wether proof abilities are to be planned

Improvements:

  • Model still need some learning ,it sees dog as a Cow and horse ;), while i dont have those two pets its okay as of now.
  • Would need to incorporate Bird classification model and capture their images just to know who visits us and if these are same birds or not, although it may be difficult i read when integrated with AWS Rekognition, it has great capabilities to identify similar faces and similar things, not sure
  • Keep a Picture Database of the birds and send those to Telegram, beauty is you can mute the channel and just have a view of the birds.
  • I have to develop the model in such a way that it fires an image only when dog eats something, typically that can be done with similar images from Public Repositories and then training a Image classification model on the same, I dont want to end up getting distracted even when dog is not really eating but trying to enjoy a walk.

Verdict

Simply an awesome tool to learn and solve some small to big problems. This project may not seem serious but I can see results with happy birds now a days, can only say better in a follow up post after a month, so far so good its been a week. I actually built it to examine cars going between 2-5am and also inspect for any person on the road in front of the home, trust me Image classification is top notch, idea is to create a group of willing
people so that they can subscribe to Telegram bot and keep an eye on the road , home cameras typically have a small range but a deeplens properly placed can cover an entire street, I deployed as a Demo and it has great results already, as and when I get better at this, it will be a community project safeguarding streets around my home in odd hours.

I love AWS and its a privilege to know its scale but also offerings, I was barely a beginner and I could start
deploying ML/AI models onto Deeplens in under 10 mins

A Near 2 year Part Time Project Done – A sustaining Model!

Leave a comment

Ever since I got interested in plants getting some sort of metrics has been a part time obsession.

Iteration 1 – No wireless and no outdoor model with always on usb power.

Iteration 2 – Learnt about ESP8266 microcontroller and deep sleep feature

Iteration 3 – Saving battery through deep sleep and battery power instead of usb mains, Adding ESP32 Microcontroller.

Iteration 4 – Study about Lithium Ion batteries

Iteration 5 – Making model wireless and usb free power, running on batteries

Iteration 6 – Containerising the entire software and integration with AWS and Telnyx

Iteration 7 – Making the model sustaining on itself through solar power and making it weather resistant

This completes an End to End IOT Model with a micro controller , a moisture sensor and two lithium ION batteries which get charged based on a small solar panel. Am going to extend this to LoRa Wan and will try to achieve ultra low power long distance.

The idea is that there is an allotment 6 kms from the place I live and I will see if AWS and LoRa Wan Supports me for protocol needs.

Docker containers associated with this project

Grafana Dashboard – Retrieving data from Influx

DeepLearning – Intro Fun

Leave a comment

I am enjoying insights into deep learning and computer vision and how machine learning is applied on images. While Deep Learning and Nueral networks are subjects for experts in field, I wanted simply to be an end user to do some experiments on my dog and nothing more. I have to mention that I had internal resources to get training on image augmentation techniques, DLL Nueral network frameworks pretrained to be used readily but am still trying to find some way into what this technology is all about and how to implement in my AWS Deeplens.

https://pytorch.org/assets/deep-learning/Deep-Learning-with-PyTorch.pdf

This is a good book to get introduced into pytorch and deep learning terminology. There is a very interesting examples of doing image manipulation of a horse to zebra, and how you can transfer that learning to anything.

Below is how I used on my Dog and results, I had fun starting this and hope you will have fun too, you dont need any great programming or math to just access some of the Neural networks and do some analysis

Normal Image

I wrote this post to let anyone interested to know that I dint had to write any complicated coding or anything just followed text, this is something you can learn in your spare time if interested.

-Rakesh

Keep up with Tech ? How Far ?

Leave a comment

One of the hardest things to do is to keep up with tech, now thats some thing every once in a while we hear from our colleagues and we might say it to ourselves as well. There are two things which needs some discussion here

  1. New certifications in Networking scope
  2. New paths like programming and cloud services

After working for a while, am at a point where I have been exposed to so many technologies within networking, there is Service provider, datacenter, enterprise and other aspects like programming and cloud services.

The choice to take both paths is not efficient if I give it a good thought, but on the other hand its always good to know other aspects of the job as well, am not trying to be diplomatic but rather speaking from experience here.

One path is to be an expert in certain aspect of the field, the other side is to invest time to learn new things, choice is not easy, any field is vast and it takes life time just to be good at one thing, imagine trying to be good at multiple things, it wont work for many people.

Other day I had to explore Amazon Athena and Amazon Glue and Finally Amazon quicksight, I have never used these services before nor I had real reason to do so, its mostly Big data aspect, but as I took a look at them for a simple task, I quickly discovered how handy these services were and what could be processed and analyzed in such a short time for someone who was looking at them for the first time.

Often times we are at a point where we need to know about many things at a nominal level, firms like Amazon has one thing in mind when they launch a service they make it easily adaptable rather than making it insanely tough and technical to understand.

I Quoted Aws, because I like AWS!

Trick to study : Always think that who ever who has better sense of business will always make it easy for people to operate and understand, and by that logic whatever you are learning just recall this that its supposed to be easy and straight forward for most of the complicated tasks as well. Technology design now a days is vested more and more about easier adaptability.

Just thought about writing about this experience as when i first saw Athena / Glue / Quicksight, I thought what am I doing with big data technology services, after spending a day or two, it was easy straight forward and I could use data to build and visualize in a certain way which made sense to my requirements, no one needs to be an expert to use a tool and complete a small task, a basic understand will suffice is what I concluded.

Happy Learning

Quick personal vpn – wireguard with aws

Leave a comment

I have written about wire-guard previously about how easy it is to set-up a personal vpn

https://r2079.wordpress.com/2020/05/16/wireguard-server-and-qr-code-scan-in-the-mobile-app-its-that-simple-to-set-up-a-vpn/

What is the issue: I have never explained the use-case clearly in that post, let me try to re-attempt the write-up again

you see, on a personal basis I need to access few websites which are hosted in India, issue with these websites is that they dont allow any traffic external to the country

There are many browser based proxies out there which can do this task just fine and also paid services, my problem is that when you are exchanging user/password information and financial transactions over these proxies you don’t know how exactly all this data getting exchanged and transmitted

Few Tips from my experience before i get into the post :

-> you need to change ubuntu instances ipv4 forwarding so that it will forward packets through the instance also nats it

root@ip-172-31-34-66:~# cat /etc/sysctl.conf | egrep -i ip_forward
net.ipv4.ip_forward=1
root@ip-172-31-34-66:~# 

-> Make sure you dont start routing everything first, take public DNS’s and test the system with allowed_ips in the configuration file else you will loose internet access and if not done correctly you will also loose access to cloud instance

-> If you want to do complicated nat and other extensions, make sure you have a public static route via AWS back to the IP

Solution:

Aws has presence all over the globe , I simply chose a free offering ubuntu instance in Asia pacific zone which covers India to setup and install wireguard VPN service.

https://aws.amazon.com/free/ – aws free tier instance

https://www.wireguard.com/install/ – Covers wireguard install

Below is my wg0.conf file and I will use wg-quick to quickly bring up this instance

Post-up and Post-Down concepts are really handy, you could ask the config file to do the NAT only when the interface is up and Delete the interface when the interface is down. This covers the server side, what about client ?

[Interface]

Address = 10.0.0.1/24 
Address = fd86:ea04:xxxx::1/64 
SaveConfig = true 
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables  -t nat -A POSTROUTING -o eth0 -j MASQUERADE 

PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; 
iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6table s -t nat -D POSTROUTING -o eth0 -j MASQUERADE ListenPort = 51820 FwMark = 0xca6c 

PrivateKey = aE7zcFky1e3BrNPKT3vFwxxxxxxxxxx 

[Peer] 
PublicKey = d+tZoJOkaNcC+x2xxxxxxxx
 AllowedIPs = 10.0.0.0/24, fd86:ea04:xxx::/64 Endpoint = xxxxx:60252

Wireguard has been supporting a client gui version as well along with QR code which we have seen.

Here is the screen-shot from my mac end-point

mac  ~ traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 52 byte packets
 1  10.0.0.1 (10.0.0.1)  768.096 ms  150.332 ms  267.774 ms
 2  ec2.ap-south-1.compute.amazonaws.com   211.881 ms
    ec2.ap-south-1.compute.amazonaws.com   432.133 ms
    ec2.ap-south-1.compute.amazonaws.com   190.867 ms
 3  100.66.8.40 (100.66.8.40)  171.070 ms
    100.66.8.198 (100.66.8.198)  166.135 ms
    100.66.8.70 (100.66.8.70)  357.351 ms
 4  100.66.10.128 (100.66.10.128)  183.827 ms
    100.66.11.228 (100.66.11.228)  311.162 ms
    100.66.11.230 (100.66.11.230)  333.343 ms
Mac configuration file

above traceroute is from my laptop and we see public DNS 8.8.8.8 is tunnelled through EC2 instance in Asia pacific region and for outside world its the natted Elastic IP on Amazon aws instance.

Hope this helps you to build a VPN of you choice instead of relying on un-known proxies.

-Rakesh

Progress on Image classification and Home-assistant and Dyson integration

Leave a comment

Contunuing from the previous post, I was determined to learn some sort of image classification in my free time, I went with Tensorflow/keras as the language or ml language as they have a lot of tutorials around it.

Below youtube series from tensor-flow team will help you get started if you are interested in this

The other part that was a sort of problem for a long time is integration of Dyson Fan with any sort of automation platform like Alexa or python api, Dyson does have an app but apparently they have some issues in UK/Ireland integration, after some research I found that home-assistant supports integration and after a lot of documentation and trials, it looks like home-assistant has now support for it.

Here is the below file that you need to use in the configuration.yaml snippet.

dyson:
username: yourdysonemailaccount
password: yourpassword
language: GB
devices:
- device_id: xxx-xx-xxxxxx
device_ip: a.b.c.d

This has now control for any sort of automation

-Rakesh

Aws Deeplens – meet the devil dog – part 1

Leave a comment

Now on first look she is so adorable, don’t be fooled by looks this dog is responsible for destruction of usb cables, foot wear , headphones, trash can openings and garden destruction.

Idea inspired from : https://youtu.be/ALKz1eKj4n0

Aws deeplens – https://aws.amazon.com/deeplens/

So here is the idea, over the course of next few days to months, I will start capturing many constructive and destructive images of my dog and start training a AI model which will give us a reasonable idea on what exactly she is up to when we leave her alone and alert us accordingly.

Am not a ML developer let alone be an expert, but aws makes it easy to train and deploy models and you don’t have to know much to get started. I developed another ML model with aws rekognition which identifies unwanted plants and shrubs in a raised bed.

I got set up this deeplens and deployed a model project in no less than 5 minutes and am being honest. Here is a sample model which identifies cat vs dog , this model comes is among example models.

It has a Mqtt topic which you can subscribe as well

-Rakesh

Improving the moisture model – the final phase

Leave a comment

Back from this post http://r2079.com/2020/03/17/telnyx-api-p-sms-and-aws-iot-saves-my-plants-every-single-time/, I did see that using Telnyx and Aws MQTT did indicate the moisture. All good, so why drag this topic ?

Links reference :

https://www.espressif.com/en/products/socs/esp32 – microcontroller used in the project

Waterproof Box
Moisture Sensor

https://vruzend.com/ – lithium ion 18650 batteries

https://micropython.org/ – micropython

http://telnyx.com/ – Telecom provider

https://aws.amazon.com/ – Cloud provider

Well, there are multiple aspects to the design itself

  1. The system always required usb external power – batteries well dint last long
  2. The system always required to be internal or inside home – reason it wasnt weather resistant
  3. Costly [ Mqtt Push and and if plant dried out, it would make Telnyx API send me a lot of messages which in turn is a cost ]
  4. I never wanted a 24×7 system, I wanted something which comes online once per day and then sort of sleeps for rest of the day
  5. Wanted to use micropython, python programming language is something I always found easy on beginners like me, where as C and CPP are difficult in my opinion.
  6. I wanted something small and less or no clumsy at all.

So I began working on the project, I always wanted this to make a self-sustaining model and in my effort, now I hope at least I could last it long. Here is what I did so far

Used a Weather-resistant, waterproof box to embed two lithium-Ion rechargeable 18650 batteries in parallel. This should technically provide ESP32 (Microcontroller) to update me 4 times / Day for least to least good 2-3 weeks and if I remove the Red LED then even more and also I can reduce the frequency

I think i finally could use the benefits of a Micro-controller like Esp32 which can deep Sleep for a good amount of time compared to Esp8266 which could only do it effectively for 70 odd minutes.

The applications are now endless, you can use the same idea for measuring, monitoring or alerting anything anywhere based on any condition that you could think of, PS I used electrical tape on the edges so that screws won’t go rusty

final Image from monitoring system looks something like this, the system is designed to get an update every 6 hours, I will write a follow-up post with the relevant code block.

The last thing this needs a small solar panel which powers the two lithiums and this will go as long as it can when placed properly in any location.

suffice to say, this helps and it already did save my plants multiple times.

-Rakesh

New hosting Space on AWS

Leave a comment

My blog was at https://r2079.wordpress.com and its now moved to https://r2079.com. Why this change?

First and Foremost – Thrill and Challenge

Secondly – Customization and Cost

Don’t get me wrong, I dint migrate because I wanted to get into web development, its not the case and Am not even at intermediate Level there!

Why – This is a custom domain. This is hosted with Route53 Amazon, WordPress is build on AWS custom instance. The Reasons are very simple

  1. I Wanted to include short flash videos in my old blog, word press apparently dint allow it
  2. Secondly, I wanted to take frequent backups – was only possible with a huge yearly cost for customization
  3. Paying for 1 Route53 domain, opened a lot of DNS options, I cancelled my Dynsubscription which was costing 54 Euros per year, while AWS would get most of it witht 12 USD.
  4. Most Importantly, I don’t have to pay anything just to block Ads!

So, This is where it is, I will try to maintain the website now and see how this goes, Till now Infrastructure was maintained and patched by WordPress , from now probably i have to take care of it.

It exciting and equally rewarding that you can customize and also get rewarded at the same time, this also opens a lot of opportunities to spin up load balancers and experiment with my AWS technical skills.

Older Entries