Close

BRAAAINS!

A project log for Prism

Prism is a smart charging station for your electric vehicle.

mastro-gippoMastro Gippo 08/12/2019 at 14:182 Comments

Of course the first thing that comes to the average makers mind when they want to add smart connectivity to something is the venerable Raspberry PI. These boards are great, but almost impossible to find in quantity and definitely impossible to buy at the advertised price if you live outside USA. The only Raspberry I could consider for size and availability is the CM version, but I'd have to add WiFi and Ethernet to the already high price of the board. Finally, they're way overpowered for my purpose. What I'm looking for is the sweet spot between a Raspberry PI and an ESP32 in terms of size, price and features.

So I started looking around for Linux SBCs. There's plenty of choice around, let's look at the best options I tested:

What these boards have in common is that they're way overpowered for the task, and priced accordingly. Trying to find a better option, I missed the most obvious one that was hanging under my nose and I was already using daily:

Routers!

I already had a lot of experience with the amazing OpenWRT project. I flashed every single router I've ever owned, built NASes, battery powered drop-boxes to crack WiFi passwords with Reaver, network bridges and more... Routers are great, are very powerful for any application not requiring graphics, are cheap, efficient and very well connected by definition. It's weird I don't see many projects using them around HackADay, kids these days only use those pesky Raspberries... Long gone are the glorious days of the WRT54GL!

One of the best platform I played with was the GL-MT300N-V2, very reliable and with plenty of CPU power (MIPS24KEc @580MHz), flash (16MB) and RAM (128MB), WiFi, Ethernet, USB host, UARTs, a nice enclosure and certification, for a very low price! It's very well supported by the tiny, rock-solid and security focused OpenWRT Linux distro.

It's based on Mediatek MT7628, a brother of the  MT7688AN. You may have never heard of them, but they're the chips powering a lot of maker platforms, sometimes combined with a microcontroller, like the Arduino Yun, the ingenious WRTnode2R with an STM32F103, the LinkIt Smart7688 with an optional Atmega32u4, the VoCore2, the Onion Omega2, the WiDora Neo and the ReSpeaker. Here's some stuff I tested:

What I love even more of this platform is that after prototyping your design with one of the aforementioned boards, there are many cheap module options that you can easily drop in your design and just work as long as you provide a stable 3.3V supply. At the time, the two best options available were the HLK-7688A and the SKW92B. I tested both, and decided for the HiLink module as it's smaller and shielded. Recently Onion introduced the Omega2S+ in a similar form factor; if it were available at the time, I would probably have chosen this part. I will definitely switch to them after the first batch that already went into production, they're slightly more expensive but it's important to reward who contributes to the community.

In the meantime, my experience with the HLK-7688A has definitely been positive. Everything worked on first try, except for a big problem: I got the 32MB flash version with a Macronix MX25L25635E that has some issues with 3bytes addressing. Basically, the system sets the flash addressing to 4bytes to use the whole 32MB flash, but the MTK7688 is configured for 3b booting. This is a problem because after a soft reboot the flash would stay in 4b mode and not switch back to 3b, so you have to do a hard reset to reboot correctly. There are a few workarounds for this:

Implementing the last option made a lot of sense for other reasons too, so I went with it. At the same time I tried contacting the manufacturer. I didn't even expect an answer, but incredibly they followed up and quickly fixed their module by replacing the flash with a Winbond part with a different command set that fixed the problem. I ordered a bunch of these news modules to test and they worked! I left the power enable workaround in place anyway, because you never know. Transistors are cheap.

OpenWRT

Using a router firmware has a lot of advantages. First of all, it's extremely compact and efficient: the base system is only 4MB. It's also very well maintained, with constant releases and quick patches for any new vulnerability. After all, you want your router to be as secure as it gets!

And, of course, it's extremely focused on connectivity. This allowed me to easily implement an Access Point mode, that is very useful for EV owners with an underground garage. This way users can monitor the state of charge of their vehicles even if the cars GSM module has no signal.

OpenWRT has a great build system with a lot of very useful packages already ported to the platform. A nice feature is the the stm32flash and avrdude integration to program microcontrollers using the MTK GPIOs. Updates are easily deployed with the internal system; the user is safe from mistakes as the important parts are read-only, and the file system is overlaid to another partition to easily reverse any mistake . I developed scripts to check updates signatures and encrypt communication with the remote server.

We'll talk more about OpenWRT in a dedicated article, where I'll show you how to compile the firmware image, use UBUS for IPC, DTS files and a few tricks I learnt along the way. In the meantime, here's my fork of the distro with the custom files for my module.

Discussions

jan.pacak wrote 09/11/2019 at 17:27 point

I have one tip for a OpenWRT project which is quite cheep, has exposed GPIO pins, USB3.0, wifi and ethernet: https://www.turris.cz/en/mox/overview/

  Are you sure? yes | no

Simon Gibson wrote 09/05/2019 at 17:47 point

Wow again! I was just thinking I could press a router into a new role of EVSE since they have most of the pieces required and are well documented! The one company I worked for I created a solution that used flashed routers to setup a VPN and required port forwarding so that equipment installed at customers sites could be remotely monitored. Works really well and provides the end users with up to date information on their equipment.

  Are you sure? yes | no