joe

joe

The best way to communicate with a RaspberryPi

Hi there,
I have a raspberry pi with a standard 16x2 display (see image).

Now I want users to be able to set the text on that display via a website powered by phoenix.

What is the best way to go here? Do I create a cluster so that the applications talk to each other directly (e.g. the raspi could run a nerves app)? Can I use sockets between 2 phoenix applications? Or do I go for a “boring” API?

What are the advantages and drawbacks of the approaches?

FYI: At a later stage I also want to connect more things to that pi and make them accessible (e.g. a webcam, LED strips, small robots, …).

Most Liked

axelclark

axelclark

I have a Nerves poncho project, all_of_the_lights, to control lights on a relay switch using Phoenix channels. The RaspberryPi runs both the Phoenix server and controls the relay switch. I interface with the Phoenix server through any web browser on my home network. The master branch uses channels. The rest_api branch uses http requests through a controller. I only have it set up so you can access the phoenix website on my home network. I’m not sure what changes would be required to access it from the web.

It uses the grovepi project to control the relay.

I just have buttons to turn the lights on and off, but you could fairly easily create a form to submit the text and then handle it in your application to update the display.

This is all I’ve done mixing Phoenix with Nerves, so I don’t know about the other approaches you mentioned.

joe

joe

Thanks for your help. So your phoenix app gets deployed and runs with nerves, right? Just like this nerves example. That is awesome. :blush:.

I guess I’ll follow the same approach, but will use a REST interface like follows:
The phoenix app running on nerves on the raspi will control the display. When it starts, it will broadcast it’s public IP to the official website. That official website runs another phoenix app and saves the location (IP) of the raspi. I’ll use port forwarding on my router to make sure that it’s reachable. The official website will forward the user input to the raspi via json REST.

What I’m unsure is how to stream the webcam. I guess that will be a challenge of it’s own and I’ll have to take a loot at webRTC.

axelclark

axelclark

Exactly right! Good luck, sounds like a fun project!

Where Next?

Popular in Questions Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement