Build a Weather Station with Elixir and Nerves: %Mint.TransportError connecting from Pi to Phoenix on host

Hi All,

I’ve followed pretty much all of the book so have most of the pieces in place. Really enjoyed it so far!

Running on a rpi4. Using wifi to talk to the rpi4. I can ssh onto and download firmware to the rpi4 no problem. I can’t seem to get measurements off the rpi4 though.

From the log I get this message every 10s when the rpi4 tries to publish the measurements to the Phoenix server on my host machine:

23:31:03.506 [debug] Server response: {:error, %Mint.TransportError{reason: :econnrefused}}

My host machine is Windows 11, with WSL2 running ubuntu. On this machine I start phx.server logs:


graham@DESKTOP-Q3UO4M4:~/weather_tracker$ mix phx.server
warning: use Mix.Config is deprecated. Use the Config module instead
config/config.exs:8

warning: use Mix.Config is deprecated. Use the Config module instead
config/dev.exs:1

[info] Running WeatherTrackerWeb.Endpoint with cowboy 2.9.0 at 0.0.0.0:4000 (http)
[info] Access WeatherTrackerWeb.Endpoint at http://localhost:4000

I’ve set up the http://localhost:4000 in mu config/target/exs as:

config :sensor_hub, :weather_tracker_url,
http://localhost:4000/api/weather-conditions

So I think I have all that correct. But I receive no measurements. When I go on to the rpi4 I only see the messages wit the TransportError.

It feels like a network config problem but I’m new to nerves and elixir would appreciate any advice you have.

Many thanks,
Graham